Fix unsubscribe + reduce bot update db query
This commit is contained in:
@@ -296,6 +296,8 @@ namespace Managing.Application.ManageBot
|
||||
|
||||
var existingBot = await _botRepository.GetBotByIdentifierAsync(bot.Identifier);
|
||||
|
||||
|
||||
|
||||
// Check if bot already exists in database
|
||||
await ServiceScopeHelpers.WithScopedService<IBotRepository>(
|
||||
_scopeFactory,
|
||||
@@ -311,7 +313,13 @@ namespace Managing.Application.ManageBot
|
||||
"Created new bot statistics for bot {BotId}: Wins={Wins}, Losses={Losses}, PnL={PnL}, ROI={ROI}%, Volume={Volume}, Fees={Fees}",
|
||||
bot.Identifier, bot.TradeWins, bot.TradeLosses, bot.Pnl, bot.Roi, bot.Volume, bot.Fees);
|
||||
}
|
||||
else
|
||||
else if (existingBot.Status != bot.Status
|
||||
|| existingBot.Pnl != Math.Round(bot.Pnl, 8)
|
||||
|| existingBot.Roi != Math.Round(bot.Roi, 8)
|
||||
|| existingBot.Volume != Math.Round(bot.Volume, 8)
|
||||
|| existingBot.Fees != Math.Round(bot.Fees, 8)
|
||||
|| existingBot.LongPositionCount != bot.LongPositionCount
|
||||
|| existingBot.ShortPositionCount != bot.ShortPositionCount)
|
||||
{
|
||||
_tradingBotLogger.LogInformation("Update bot statistics for bot {BotId}",
|
||||
bot.Identifier);
|
||||
|
||||
Reference in New Issue
Block a user