Commit Graph

91 Commits

Author SHA1 Message Date
c4e444347c Fix bot update with the tradingtype 2025-12-13 14:46:30 +07:00
5328d760dd Add support for backtesting trading types in LiveTradingBotGrain and TradingBox
- Introduced handling for TradingType.BacktestFutures and TradingType.BacktestSpot in LiveTradingBotGrain.
- Updated TradingBox to map backtest trading types to their respective futures and spot types.
2025-12-11 23:41:53 +07:00
a07d7ede18 Fix backtest spot 2025-12-03 16:47:32 +07:00
c932fef289 Add spot trading 2025-12-02 14:38:54 +07:00
3771bb5dde Refactor SwapGmxTokens functionality into TradingService
- Moved SwapGmxTokensAsync method from AccountService to TradingService to centralize trading operations.
- Updated AccountController and AgentGrain to utilize the new TradingService method for swapping GMX tokens.
- Removed the old SwapGmxTokensAsync method from IAccountService and its implementation in AccountService.
2025-12-01 22:49:30 +07:00
Oda
9d536ea49e Refactoring TradingBotBase.cs + clean architecture (#38)
* Refactoring TradingBotBase.cs + clean architecture

* Fix basic tests

* Fix tests

* Fix workers

* Fix open positions

* Fix closing position stucking the grain

* Fix comments

* Refactor candle handling to use IReadOnlyList for chronological order preservation across various components
2025-12-01 19:32:06 +07:00
47bea1b9b7 Update closing position on BotStop 2025-11-23 23:31:34 +07:00
6429501b70 Add more logs for auto-close on owned keys 2025-11-23 22:57:30 +07:00
d10ce5e3ba Enhance error handling and logging in BotController, LiveTradingBotGrain, and BotService
- Added specific handling for ServiceUnavailableException in BotController to return user-friendly messages.
- Improved logging for Orleans exceptions in both BotController and BotService to provide clearer context during errors.
- Implemented verification of position closure status in LiveTradingBotGrain, including timeout handling for closing positions.
- Enhanced logging for critical and non-critical operations during bot stop processes to ensure better traceability.
2025-11-23 21:48:21 +07:00
153e170ca4 Refactor LiveBotRegistryGrain and PlatformSummaryGrain to improve active bot tracking
- Introduced CalculateActiveBotsCount method in LiveBotRegistryGrain to streamline active bot count calculations.
- Updated logging to reflect active bot counts accurately during registration and unregistration.
- Added historical tracking of strategy activation/deactivation events in PlatformSummaryGrain, including a new StrategyEvent class and related logic to manage event history.
- Enhanced CalculateActiveStrategiesForDate method to compute active strategies based on historical events.
2025-11-21 19:38:32 +07:00
4d4e5b6d25 Update position value calculations in AgentGrain and BotService
- Changed the calculation of USDC value in AgentGrain to use net profit and loss instead of realized profit.
- Added similar position value calculations in BotService, including error handling for position retrieval failures.
2025-11-20 20:34:12 +07:00
190a9cf12d Finish copy trading 2025-11-20 14:46:54 +07:00
ff2df2d9ac Add MasterBotUserId and MasterAgentName for copy trading support
- Introduced MasterBotUserId and MasterAgentName properties to facilitate copy trading functionality.
- Updated relevant models, controllers, and database entities to accommodate these new properties.
- Enhanced validation logic in StartCopyTradingCommandHandler to ensure proper ownership checks for master strategies.
2025-11-20 00:33:31 +07:00
97103fbfe8 Add master strategy validation in LiveTradingBotGrain
- Introduced a check to ensure the master strategy is retrieved successfully before proceeding with key validation.
- Added logging for cases where the master strategy is not found, improving traceability in the bot's operation.
2025-11-19 23:39:38 +07:00
096fb500e4 Add position count property map 2025-11-19 14:16:30 +07:00
c229212acd Add copy trading authorization checks in LiveTradingBotGrain and StartCopyTradingCommandHandler. Integrated IKaigenService to verify user ownership of master strategy keys before allowing copy trading. Enhanced error handling and logging for authorization verification. 2025-11-16 22:11:54 +07:00
ec88b124e6 Refactor LiveTradingBotGrain to close all open positions before stopping the bot. Introduced CloseAllOpenPositionsAsync method to handle position closure and logging, ensuring a smoother stop process. Removed the previous check for open positions in the database. 2025-11-16 18:22:48 +07:00
1e15d5f23b Add copy trading functionality with StartCopyTrading endpoint and related models. Implemented position copying from master bot and subscription to copy trading stream in LiveTradingBotGrain. Updated TradingBotConfig to support copy trading parameters. 2025-11-16 14:54:17 +07:00
6d661f459e Remove candle from backtest return + fix message when good backtest 2025-11-14 20:49:02 +07:00
b60295fcb2 Add test for dailysnapshot 2025-11-14 19:42:52 +07:00
d341ee05c9 Add more tests + Log pnl for each backtest 2025-11-14 13:12:04 +07:00
460a7bd559 Fix realized pnl on backtest save + add tests (not all passing) 2025-11-14 02:38:15 +07:00
2dc34f07d8 Add yield for orleans + 1min to 2h timeout for grain message + more exception send to sentry 2025-11-07 12:40:24 +07:00
5afddb895e Add async for saving backtests 2025-11-05 16:58:46 +07:00
79f07af899 Fix get Balance 2025-10-20 16:20:36 +07:00
472c507801 Add netpnl and initialBalance to backtests 2025-10-16 17:19:22 +07:00
49b0f7b696 Fix restart with no accountName 2025-10-12 16:28:53 +07:00
ff74296c26 Fix restart/start if not account with the first account of the user 2025-10-12 16:08:12 +07:00
117d45fb50 Do not stop bot if position open 2025-10-11 00:32:02 +07:00
d71d47f644 Add reason when stopping bot 2025-10-10 23:31:32 +07:00
54fc08d71a Add logs and backtest requester 2025-10-10 02:15:44 +07:00
21314430ef Reduce logs for backtests 2025-10-10 01:59:27 +07:00
ffb98fe359 Fix update agent save + revert market in redis 2025-10-08 21:32:48 +07:00
fa160e2d1b Update messages 2025-10-08 20:30:57 +07:00
b2a4e1ca5d Fix agent volume 2025-10-08 19:57:19 +07:00
1a99224d18 Fix ROI calculation for Strategy 2025-10-08 19:37:24 +07:00
76b087a6e4 Fix status and filtered positions for metrics 2025-10-08 18:37:38 +07:00
86dd6849ea Fix status IsFinished/IsOpen/IsForMetrics + use redis for markets on gmx.tsx instead of inmemory cache 2025-10-08 12:13:04 +07:00
67065469a6 Fix config update + remove messages + Summary fix for not open position 2025-10-08 02:52:11 +07:00
ff7e4ed3d3 un-stopped bot return status "stopped" instead of the error 2025-10-07 16:10:14 +07:00
719ce96e11 Fix lastStartTime update 2025-10-07 02:00:39 +07:00
347c78afc7 Update messaging 2025-10-06 01:34:13 +07:00
dab4807334 Fix Runtime 2025-10-06 00:55:18 +07:00
f67ee330b3 Fix Runtime by adding TotalRuntimeInSeconds 2025-10-05 20:51:46 +07:00
b25f0be083 Remove extra message on the low usdc while position open 2025-10-05 02:49:33 +07:00
de0d042254 Use usdc balance instead usdc value for ensuring balance check 2025-10-05 01:36:25 +07:00
343b85dada Fix fetch and restart bot 2025-10-04 18:31:50 +07:00
15eba0fc3c Prevent bot from stopping if position is open 2025-10-04 17:43:43 +07:00
3635fb4c29 Use bot allocation on running strategies only 2025-10-04 13:54:14 +07:00
f72bfc4ab8 Update balance tracking 2025-10-03 16:43:20 +07:00