Update position worker (#11)

* Update position worker

* Update todo
This commit is contained in:
Oda
2025-02-20 12:06:15 +07:00
committed by GitHub
parent d7731dda0e
commit 160fd02aac
9 changed files with 199 additions and 133 deletions

View File

@@ -87,50 +87,11 @@
- [x] Create channel handler for address watcher
- [x] Add input to specify the account balance. If not set, it will use the selected account balance
# The rest
## 4 - Trading desk [Link](https://github.com/users/CryptoOda/projects/1/views/1?pane=issue&itemId=11070087)
## Part 1 : Adaptive trading
- [x] From backtests list : Determine TP and Stop loss % by getting average profit and average lost for a signal
- [x] Modify bot to use MoneyManagement object instead of using the risk associated to the signal.
- [x] Bot object should return MoneyManagement object
- [ ] Strategy can return a suggested trade that will give the best orders to execute
## Part 2 : Workflows builder (Post-pawned)
- [x] Create a workflow type that will encapsulate a list of flows
- [x] Each flow will have parameters, inputs and outputs that will be used by the children flows
- [ ] Flow can handle multiple parents
- [ ] Run Simple bot base on a workflow
- [ ] Run backtest based on a workflow
- [ ] Add flows : ClosePosition, Scenario
## Part 2 : Strategies optimisation
- [ ] Optimize all strategies with more data (funding rate trend, bbwp, etc..)
- [ ] Optimize entry by getting last ask price and place an order limit to match directly with it
- [ ] Add bbwp indicator => PR
example : https://github.com/DaveSkender/Stock.Indicators/pull/893/files#diff-df1cd2a99846f7328c9fc3db4d2c164380a0fa943cdcad2ece01b886cac68137
- [ ] Create strategies types from signal (a divergence) / trend (stoch long or short) / context (high vol/low vol)
- [ ] Create a trend strategy on fundinrate -> long trend if negativ fr / short trend if positiv fr
- [ ] Add entry/exit price to signal for adaptive risk
- [ ] MACD: Open only when candle is not a big move to avoid late entry (only enter when low vol)
- [ ] Improve strategy composability by using delegate pattern
## Part 3 : Backtests automation
- [ ] Create a worker that determine best TP and SL
- [ ] Create a page 'Analyze' to show the best TP and SL for multiple backtest result
- [ ] Implement reverseSignal to close and flip the trade
- [ ] Load signal from database
- [ ] Create a bot to update signal into database that still in pending
- [ ] Signal return best SL and TP
- [ ] Combine multi-timeframe to detect better signals => Adapt risk on the lowest timeframe based on upper timeframe
- [ ] Remove candles from the backtestResult
- [ ] Save start/end time and timeframe into the result
- [ ] On GET backtest -> Retrieve the candle from cache or database
_______________________________________________________________________________________________________________
- [x] Live data position hub
- [x] Live candles
- [x] Open position from desk
# Phase 2 - Web3
@@ -141,29 +102,47 @@ ________________________________________________________________________________
- [x] Close trade
- [ ] Update position / TP / SL
## 0 - GMX v2
## Bots
## 1 - Wallet management
- [x] Add button to display money management use by the bot
- [ ] POST POWNER - On the modarl, When simple bot selected, show only a select for the workflow
- [ ] Create onboarding process for new wallet
- [ ] User can deposit token to and evm account with a QR code or clicking on button to copy the address
- [ ] Add account abstraction to level up security
## Workflow
## 2 - [Track address](https://github.com/users/CryptoOda/projects/1/views/1?pane=issue&itemId=32158941)
- [x] List all workflow saved in
- [x] Use https://reactflow.dev/ to display a workflow (map flow to nodes and children to edges)
- [x] On update Nodes : https://codesandbox.io/s/dank-waterfall-8jfcf4?file=/src/App.js
- [x] Save workflow
- [ ] Reset workflow
- [ ] Add flows : Close Position, SendMessage
- [ ] On Flow.tsx : Display inputs/outputs names on the node
- [ ] Setup file tree UI for available flows : https://codesandbox.io/s/nlzui
- [x] Create a workflow type that will encapsulate a list of flows
- [x] Each flow will have parameters, inputs and outputs that will be used by the children flows
- [ ] Flow can handle multiple parents
- [ ] Run Simple bot base on a workflow
- [ ] Run backtest based on a workflow
- [ ] Add flows : ClosePosition, Scenario
- [ ] Create a snapshot of the account balances with BalancesWorker
- [ ] Display balance in $ evolution per token hold on the account page
## Backtests
## 3 - Settings [Link](https://github.com/users/CryptoOda/projects/1/views/1?pane=issue&itemId=32159287)
- [x] Display the money management used by the backtest
- [ ] Save theme into database
- [ ] Call GET Settings/Theme to retrieve the theme used by the user
## Part 1 : Adaptive trading
## 4 - Trading desk [Link](https://github.com/users/CryptoOda/projects/1/views/1?pane=issue&itemId=11070087)
- [x] From backtests list : Determine TP and Stop loss % by getting average profit and average lost for a signal
- [x] Modify bot to use MoneyManagement object instead of using the risk associated to the signal.
- [x] Bot object should return MoneyManagement object
- [x] Bot backup worker: Every x, get saved bots and check if still running. If not running call api to reboot bot.
- [x] Factorize amount management for GMX Service
- [x] Create worker to fetch the biggest spread between long\short funding rate and send alert when most profitable
delta neutral position is found
- [x] Create a worker to scrap funding fees over time (per ticker, per exchange)
-
- [x] Live data position hub
- [x] Live candles
- [x] Open position from desk
## Scenarios
- [ ] Create a blocky-like editor to create scenarios https://google.github.io/blockly-samples/
## 5 - Live liquidation map
@@ -172,31 +151,94 @@ ________________________________________________________________________________
- [ ] Live data signal
- [ ] Display massive liquidation on TradeChartWidget
## 6 - Metrics [Link](https://github.com/users/CryptoOda/projects/1/views/1?pane=issue&itemId=32159107)
## To review
- [ ] ???? Improve strategy composability by using delegate pattern ????
- [ ] Post-powned - Load signal from database
- [ ] Create a bot to update signal into database that still in pending
- [ ] Signal return best SL and TP
- [ ] Extract BacktestReport from tests to a Tools projects
- [ ] Remove link betweend Domain object to EVM project
- [ ] GMX Service should handle only Nethereum object, not Domain.Models
- [ ] Compute backtests pagination on backend side
- [ ] Implement from/to tickers array pattern
_______________________________________________________________________________________________________________
# Before Kudai
## Part 1 : Strategies optimisation
- [ ] Create strategies types from signal (a divergence) / trend (stoch long or short) / context (high vol/low vol)
- [ ] Strategy can return a suggested trade that will give the best orders to execute
- [ ] Optimize all strategies with more data (funding rate trend, bbwp, etc..)
- [ ] Add entry/exit price to signal for adaptive risk
- [ ] Add bbwp indicator => PR
example : https://github.com/DaveSkender/Stock.Indicators/pull/893/files#diff-df1cd2a99846f7328c9fc3db4d2c164380a0fa943cdcad2ece01b886cac68137
- [ ] Optimize entry by getting last ask price and place an order limit t match directly with it
- [ ] Create a trend strategy on fundinrate -> long trend if negativ fr / short trend if positiv fr
- [ ] MACD: Open only when candle is not a big move to avoid late entry (only enter when low vol)
## Part 2 : Backtests automation
- [x] Save start/end time and timeframe into the result
- [ ] Create a worker that determine best TP and SL
- [ ] Create a page 'Analyze' to show the best TP and SL for multiple backtest result
- [ ] Implement reverseSignal to close and flip the trade
- [ ] Combine multi-timeframe to detect better signals => Adapt risk on the lowest timeframe based on upper timeframe
- [ ] Remove candles from the backtestResult
- [ ] On GET backtest -> Retrieve the candle from cache or database
- [ ] Create a worker that get top 5 cryptos by scenario
- [ ] Create worker to store portofolio evolution
- [ ] Display portofolio evolution
- [ ] Create a worker to scrap funding fees over time (per ticker, per exchange)
## Part 3 - Wallet management
- [ ] Create onboarding process for new wallet
- [ ] User can deposit token to and evm account with a QR code or clicking on button to copy the address
- [ ] Add account abstraction to level up security with privy
- [ ] Display balance in $ evolution per token hold on the account page
- [ ] Create a snapshot of the account balances with BalancesWorker
## 7 - Improvement [Link](https://github.com/users/CryptoOda/projects/1/views/1?pane=issue&itemId=32159127)
- [ ] Handling user on every object => Use the JWT token to inject the userName
- [ ] Extract BacktestReport from tests to a Tools projects
- [ ] Factorize amount management for GMX Service
- [ ] Remove link betweend Domain object to EVM project
- [ ] GMX Service should handle only Nethereum object, not Domain.Models
- [ ] Compute backtests pagination on backend side
- [x] Store webapp into docker
- [ ] Make possible to force close all positionpositions of a bot
- [ ] Save bot config to easily relaunch a bot and also analyze data
- [ ] Bot can handle limit order position -> fetch if order is still open then check if position of open
- [ ] Create method to update the money management use by the bot
- [ ] Implement from/to tickers array pattern
- [ ] Extract all managing trade method into a TradingBox class => Create composable trading bot type easily
- [ ] Bot backup worker: Every x, get saved bots and check if still running. If not running call api to reboot bot.
- [ ] Create worker to fetch the biggest spread between long\short funding rate and send alert when most profitable
delta neutral position is found
## Backend :
- [ ] Filter all objects by users using botpress profiles
- [ ] Create endpoint to calculate the total volume traded
- [ ] Integrate Privy APIs to sign tx
- [ ] Get wallet balanced through Privy
- [ ] Remove Timeframe for strategies
- [ ] Update bot scenarios => shouldn't close current open position
- [ ] Remove accountName from getTicker
- [ ] Add enddate to backtest
- [ ] Replace WatchOnly by PaperTrading
## Botpress :
- [ ] Manage agent profiles
- [ ] Setup chat workflow
- [ ] Setup bad behaviors
- [ ] Setup chat for: create wallet, create strategy
## N8N pipelines:
- [ ] Create wallet: Check funds, approve usdc
- [ ] Create strategy: Get indicators, tickers and money management infos and call Managing.API
- [ ] Agent performance update
## Infra :
- [ ] Install botpress and n8n
- [ ] Setup botpress chat and language interpretation
- [ ] Add Tyk API Gateway for rate limit between n8n and Managing API
- [ ] New database Postgre for N8N and Botpress (agent profiles, built strategies, stats)
_____________________________________________________________________________________________________________
# Front-end
@@ -214,22 +256,14 @@ ________________________________________________________________________________
## Trading desk
- [ ] WAIT - Create a button to open a hedge on option market
- [ ] Get global exposure ((total position / total balances *) 100)
- [ ] WAIT - Create a button to open a hedge on option market
- [ ] Display multiple tab to show different tickers
## Scenarios
## 3 - Settings [Link](https://github.com/users/CryptoOda/projects/1/views/1?pane=issue&itemId=32159287)
- [x] Create a blocky-like editor to create scenarios https://google.github.io/blockly-samples/
## Bots
- [ ] Add button to display money management use by the bot
- [ ] On the modal, When simple bot selected, show only a select for the workflow
## Backtests
- [x] Display the money management used by the backtest
- [ ] Save theme into database
- [ ] Call GET Settings/Theme to retrieve the theme used by the user
## Technical front-end :
@@ -237,26 +271,17 @@ ________________________________________________________________________________
- [ ] Make Get Accounts List as a store
- [ ] Replace all html-tag Modals (ex: BacktestPlayground.tsx)
- [ ] Refactoring Components :
- organism : Put all the code related to the app (Trade charts etc). This folder should be delete when the project is
forked
- mollecules : Put aggregate of atoms to create forms/modal/table
- atoms : Put all basic html tag components (List, Select, Slider...)
## Workflow
- [x] List all workflow saved in
- [x] Use https://reactflow.dev/ to display a workflow (map flow to nodes and children to edges)
- [x] On update Nodes : https://codesandbox.io/s/dank-waterfall-8jfcf4?file=/src/App.js
- [x] Save workflow
- [ ] Reset workflow
- [ ] Add flows : Close Position, SendMessage
- [ ] On Flow.tsx : Display inputs/outputs names on the node
- [ ] Setup file tree UI for available flows : https://codesandbox.io/s/nlzui
- organism : Put all the code related to the app (Trade charts etc). This folder should be delete when the project
is
forked
- mollecules : Put aggregate of atoms to create forms/modal/table
- atoms : Put all basic html tag components (List, Select, Slider...)
_____________________________________________________________________________________________________________
# Technicals
- [x] Store webapp into docker
- [ ] Remove mediator
- [ ] Check Traefik : https://www.cloudbees.com/blog/setting-up-traefik-as-a-reverse-proxy-for-asp-net-applications
- [ ] Implement IHostedService/BackgroundService to run bot in background https://www.youtube.com/watch?v=fw-n2RkzOMI