Implement balance update callback in TradingBotBase for immediate sync

- Removed the private _currentBalance field and replaced it with direct access to Config.BotTradingBalance.
- Added OnBalanceUpdatedCallback to TradingBotBase for immediate synchronization and database saving when the balance is updated.
- Updated LiveTradingBotGrain to set the callback for balance updates, ensuring accurate state management.
- Modified PostgreSqlBotRepository to save the updated bot trading balance during entity updates.
This commit is contained in:
2026-01-09 03:34:35 +07:00
parent 8d4be59d10
commit ae353aa0d5
3 changed files with 37 additions and 6 deletions

View File

@@ -83,6 +83,7 @@ public class PostgreSqlBotRepository : IBotRepository
existingEntity.AccumulatedRunTimeSeconds = bot.AccumulatedRunTimeSeconds;
existingEntity.MasterBotUserId =
bot.MasterBotUserId ?? existingEntity.MasterBotUserId;
existingEntity.BotTradingBalance = bot.BotTradingBalance;
await _context.SaveChangesAsync().ConfigureAwait(false);
}