# V2

## Done

### Adaptive mode

- [x]  Create a risk mode 'Adaptive' to be able to not use save moneymanagement settings
- [x]  Adaptive mode will force Bot to determine SL by getting the previous highest price on the period (prevent choppy
  price on good entry)
- [x] Create account (type, exchange, key, secret)
- [x] Update trading bot to handle one account
- [x] Remove exchange from bot. Exchange will be set on the account
- [x] Update ftxClient to not use Managingbot subaccount
- [x] Update exchangeService to handle account
- [x] Dynamic Ticker selection base on best volumes on the exchanges
- [x] Create endpoint to get the ticker list for the frontend
- [x] Create method in application to get best bid and best ask
- [x] Submit only limit with IOC
- [x] Implement Poly to have a retry policy for limit order ioc execution => Unsure position is open
- [x] For openOrder inject a parameter to select the ioc mode. If risk is adaptive we just place the order a the price
  without forcing the position opening
- [x] Integrate STC signals

### Web3

- [x] Integrate wallet management from backend side
- [x] Integrate wagmi/connectkit
- [x] Sign message with connectkit
- [x] On wallet connect, check if token is not expired
- [x] User can have multiple address
- [x] User can create an account base on evm exchange
- [x] Hide key/secret if evm exchange is selected
- [x] Generate pub/priv key on evm account creation and store it into mongo
- [x] Get balance for an address
- [x] Handle multi-chain
- [x] Add arbitrum testnet for backend
- [x] User can withdraw found to the connected address of the user
- [x] Implement get balance with chainlink feed
- [x] Abstract subgraph management
- [x] Get price from multiple price feeds subgraph
- [x] Add to ExchangeService GetAvailableTicker()
- [x] Add get token list method to EvmManager
- [x] Setup worker to save candles into db
- [x] Open trade -> CreateIncreaseOrder
- [x] Close trade -> CreateDecreasePosition
- [x] Close all orders
- [x] Create SL & TP -> CreateDecreaseOrder
- [x] Get Fees -> Estimate Tx cost
- [x] Adapt GetBalance to retrieve stablecoin amount
- [x] Create worker to fetch GMX leaderboard -> LeaderboardWorker
- [x] Leaderboard will create PositionUpdate message bus to deposit a message with all information to open a trade
- [x] Create bot type CopyTrading to receive PositionUpdate bus message and open position based on criteria
- [x] CopyTrading bot will send an OpenPosition button on Discord if he's set to watchOnly
- [x] Fix : Trim address, give name to address, decrease amount bug,
- [x] Display best last backtests ran by backtester workers
- [x] Refactor GetAccounts/GetAccount to handle the user
- [x] AccountType : Binance/EvmTrador/EvmWatch/EvmPersonal
- [x] Make better abstration of the Database projects (influx, mongodb) to Remove the link between Application and
  Infrastructure
- [x] Implement strategy pattern for exchange processors
- [x] Use cache for position and signal
- [x] Don't run update Signal and manage position if no new candle

### Workers

- [x] Add Influxdb
- [x] Create workers for scrap data (per ticker, per exchange, per timeframe)
- [x] Use candle from influxdb for backtests and bots
- [x] Create a worker that get a daily top 15 of ticker volume
- [x] Scrap candle only for crypto with high volume
- [x] Create a worker that run backtest and save it in db

### Front-end

- [x] Return list of balances with tokens/chains data
- [x] On account line click, display tokens by chain available
- [x] Call Available ticker to produce the droplist
- [x] Display
  multipanes https://github.com/qwpto/lightweight-charts-panels / https://codesandbox.io/s/react-typescript-forked-mxek17?file=/src/App.tsx / https://github.com/Rassibassi/multipane_tradingview
- [x] Display last open position with lines (add SL and TP)
- [x] Fix double charts problem (has been fixed by removing strict mode)
- [x] Try to pass the tailwind current theme color to the chart
- [x] List all open position for every trading account
- [x] Create button to force close position
- [x] Open Position button
- [x] Improve position message -> Create message buildor
- [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

## 4 - Trading desk [Link](https://github.com/users/CryptoOda/projects/1/views/1?pane=issue&itemId=11070087)

- [x] Live data position hub
- [x] Live candles
- [x] Open position from desk

# Phase 2 - Web3

- [x] Cancel Orders
- [x] Get open orders
- [x] Open trade (Increase position, decrease position)
- [x] Get position
- [x] Close trade
- [ ] Update position / TP / SL

## Bots

- [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


## Backtests

- [x] Display the money management used by the backtest

## 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
- [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)
-

## Scenarios

- [ ] Create a blocky-like editor to create scenarios https://google.github.io/blockly-samples/

## 5 - Live liquidation map

- [ ] Create worker to aggregate binance/okx liquidation
- [ ] Render liquidation map with a hub subscription to get live update
- [ ] Live data signal
- [ ] Display massive liquidation on TradeChartWidget

## 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

## 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
- [ ] Make possible to force close all positionpositions of a bot
- [ ] 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
- [ ] Extract all managing trade method into a TradingBox class => Create composable trading bot type easily

## 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)

- [ ] Deploy database for Chat and Agent Profiles

_____________________________________________________________________________________________________________

# Front-end

## Improve Account page

- [ ] Display total balances (only trader account) on Settings->Accounts Page
- [ ] On Token Account details line -> Add button to withdraw money  (this will open a Modal to prompt the
  address/amount that will receive the money)

## Charts

- [ ] Add multi-timeframe options
- [ ] Display optionnal indicators on charts
- [ ] Display current selected position (when i click on a Position in the list)

## Trading desk

- [ ] 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

## 3 - Settings [Link](https://github.com/users/CryptoOda/projects/1/views/1?pane=issue&itemId=32159287)

- [ ] Save theme into database
- [ ] Call GET Settings/Theme to retrieve the theme used by the user

## Technical front-end :

- [ ] Implement alias to reduce 'import' lines https://github.com/subwaytime/vite-aliases
- [ ] 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...)

_____________________________________________________________________________________________________________

# 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
- [ ] Implement Microsoft Orleans
