Commit Graph

113 Commits

Author SHA1 Message Date
bc4725ca19 Refactor FuturesBot and SpotBot to utilize ticker enum for candle retrieval
- Updated GetCurrentCandleForPositionClose method in both FuturesBot and SpotBot to parse the ticker parameter into an enum, enhancing type safety and clarity.
- Adjusted TradingBotBase to use the position's ticker for candle retrieval, ensuring consistency across trading bot implementations.
2026-01-07 01:44:05 +07:00
96dd9086c5 Update startup message in TradingBotBase to reflect strategy initiation; modify displayed information to include market type and remove scenario name for clarity. 2025-12-26 16:54:47 +07:00
7a3ede03ca Add balance tracking on bot start/restart; implement TrackBalanceOnBotStartAsync in IAgentGrain and AgentGrain, and trigger it in LiveTradingBotGrain. Enhance logging for balance tracking operations. 2025-12-26 15:43:46 +07:00
e9b4878ffa Refactor BacktestExecutor and TradingBotBase for performance optimizations; remove unused SignalCache and pre-calculation logic; implement caching for open position state and streamline signal access with TryGetValue; enhance logging for detailed timing breakdown during backtest execution. 2025-12-20 10:05:07 +07:00
65d00c0b9a Add reconcilliation for cancelled position if needed 2025-12-11 18:35:25 +07:00
df8c199cce Clean tradingbot and spot and future 2025-12-11 14:10:38 +07:00
8ff9437400 Fix a bit the spot trading 2025-12-10 23:16:46 +07:00
15d8b38d8b Adapt spot for recovery 2025-12-05 15:24:51 +07:00
78edd850fe Add isLiveTrading helper to fix bug 2025-12-04 23:42:09 +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
ab26260f6d Prepare for refactoring 2025-11-26 19:26:57 +07:00
cef8073314 Remove comments 2025-11-26 10:38:24 +07:00
6429501b70 Add more logs for auto-close on owned keys 2025-11-23 22:57:30 +07:00
461a73a8e3 Add MasterBot configuration properties to TradingBotBase and ensure MasterBotUserId preservation in RestartBotCommandHandler
- Introduced IsForCopyTrading, MasterBotIdentifier, and MasterBotUserId properties in TradingBotBase for enhanced bot configuration.
- Updated RestartBotCommandHandler to preserve MasterBotUserId from the database bot configuration.
2025-11-22 15:42:17 +07:00
aa8a723aad Dont display indicators use on copied strategy 2025-11-20 22:14:44 +07:00
190a9cf12d Finish copy trading 2025-11-20 14:46:54 +07:00
c7adb687b8 Fix recovery positions 2025-11-19 21:06:02 +07:00
f56d75d28f Fix loop when trying to recover the cancelled position 2025-11-19 20:23:44 +07:00
030a6b0eba Fix bot running signal 2025-11-18 23:02:38 +07:00
52c11e30c4 Refactor TradingBotBase to manage current balance more effectively. Introduced _currentBalance field to track balance updates during trading operations. Updated wallet balance logic to utilize _currentBalance for consistency. Added new entries to performance benchmark CSV files for recent test runs. 2025-11-17 23:53:53 +07:00
091f617e37 Update configuration files for production, sandbox, and local environments. Changed Kaigen BaseUrl and database connection strings to point to new server addresses. Adjusted CORS allowed origins and authentication valid audiences for improved security and functionality. 2025-11-17 22:59:15 +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
61ade29d4e Remove logs for position update on pnl 2025-11-14 13:39:39 +07:00
d341ee05c9 Add more tests + Log pnl for each backtest 2025-11-14 13:12:04 +07:00
2548e9b757 Fix all tests 2025-11-14 04:03:00 +07:00
460a7bd559 Fix realized pnl on backtest save + add tests (not all passing) 2025-11-14 02:38:15 +07:00
2cc6cc5dee Refactor BacktestExecutor to use net PnL calculations consistently across methods. Updated variable names for clarity and ensured final results reflect net profit after fees. Minor adjustment in TradingBotBase to directly access net PnL from position profit and loss. 2025-11-13 11:56:11 +07:00
6d6f70ae00 Fix SLTP for backtests 2025-11-12 23:52:58 +07:00
3b176c290c Update precalculated indicators values 2025-11-12 23:26:12 +07:00
e0d2111553 Fix positions for backtests 2025-11-12 19:45:30 +07:00
e8a21a03d9 Refactor TradingBotBase to remove unnecessary debug logging and streamline position recovery checks. Improved clarity in position management by eliminating redundant code. 2025-11-12 00:58:33 +07:00
8d97fce41c Refactor TradingBotBase to streamline recovery logic for recently canceled positions. Removed redundant recovery call and added comments for clarity in position management. 2025-11-12 00:50:16 +07:00
2057c233e5 Enhance TradingBotBase with recovery logic for recently canceled positions and improved error handling for Web3Proxy. Updated CheckPositionInExchangeHistory to return error status, ensuring robust position verification and cancellation processes. 2025-11-12 00:41:39 +07:00
903413692c Add precalculated signals list + multi scenario test 2025-11-11 14:05:09 +07:00
fc036bb7de docs: enhance benchmark command with business logic validation tests
- Add 2 ETH-based validation tests to benchmark script
- Validates ExecuteBacktest_With_ETH_FifteenMinutes_Data_Should_Return_LightBacktest
- Validates ExecuteBacktest_With_ETH_FifteenMinutes_Data_Second_File_Should_Return_LightBacktest
- Ensures performance optimizations don't break trading logic
- Update command documentation with comprehensive validation details
- All 3 validation levels must pass for benchmark success
2025-11-11 12:32:56 +07:00
61fdcec902 perf: remove debug logging and optimize rolling window maintenance (+5.0%) 2025-11-11 12:26:44 +07:00
46966cc5d8 perf: optimize TradingBotBase and TradingBox - reduce LINQ overhead and allocations (+31.1%) 2025-11-11 12:21:50 +07:00
1792cd2371 Fix backtest consistency 2025-11-11 12:15:12 +07:00
567de2e5ee Add benchmark + fix bundle that should be completed 2025-11-11 11:35:48 +07:00
1d70355617 Optimze worker for backtest 2025-11-11 03:59:41 +07:00
51a227e27e Improve perf for backtests 2025-11-10 02:15:43 +07:00
db6e06ad5d Do not check signal if position open and flipping is off 2025-11-05 10:56:07 +07:00
1079f38ed7 Add exception for webhook + add gracefull time before market decrease 2025-11-05 10:54:14 +07:00
60035ca299 Fix pnl calculation when force closed 2025-11-03 19:26:48 +07:00
ce43bbf31f Remove debug for position updated 2025-10-27 11:05:15 +07:00
abd5eb675c Re-update internal balance before opening position 2025-10-27 10:25:45 +07:00
f816b8de50 Update fetch borkerPosition in bot + better HandleClosePosition + Add debug channel to receive all debug 2025-10-25 18:35:51 +07:00
38e6998ff3 Add test to check if backtest behavior changed 2025-10-24 19:08:10 +07:00
fc4369a008 Add start and enddate when fetching the position history 2025-10-24 18:00:23 +07:00
554cac7d89 Check direction of the position before updating the broker position 2025-10-24 02:41:40 +07:00