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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user