Add platform grain

This commit is contained in:
2025-08-14 19:44:33 +07:00
parent 345d76e06f
commit 4a45d6c970
13 changed files with 2324 additions and 59 deletions

View File

@@ -633,6 +633,12 @@ public class LiveTradingBotGrain : Grain, ILiveTradingBotGrain, IRemindable
.Sum(p => p.Open.Quantity * p.Open.Price);
var roi = totalInvestment > 0 ? (pnl / totalInvestment) * 100 : 0;
// Calculate long and short position counts
var longPositionCount = _tradingBot.Positions.Values
.Count(p => p.OriginDirection == TradeDirection.Long);
var shortPositionCount = _tradingBot.Positions.Values
.Count(p => p.OriginDirection == TradeDirection.Short);
// Create complete Bot object with all statistics
bot = new Bot
{
@@ -648,7 +654,9 @@ public class LiveTradingBotGrain : Grain, ILiveTradingBotGrain, IRemindable
Pnl = pnl,
Roi = roi,
Volume = volume,
Fees = fees
Fees = fees,
LongPositionCount = longPositionCount,
ShortPositionCount = shortPositionCount
};
}
@@ -659,8 +667,8 @@ public class LiveTradingBotGrain : Grain, ILiveTradingBotGrain, IRemindable
if (success)
{
_logger.LogDebug(
"Successfully saved bot statistics for bot {BotId}: Wins={Wins}, Losses={Losses}, PnL={PnL}, ROI={ROI}%, Volume={Volume}, Fees={Fees}",
_state.State.Identifier, bot.TradeWins, bot.TradeLosses, bot.Pnl, bot.Roi, bot.Volume, bot.Fees);
"Successfully saved bot statistics for bot {BotId}: Wins={Wins}, Losses={Losses}, PnL={PnL}, ROI={ROI}%, Volume={Volume}, Fees={Fees}, Long={LongPositions}, Short={ShortPositions}",
_state.State.Identifier, bot.TradeWins, bot.TradeLosses, bot.Pnl, bot.Roi, bot.Volume, bot.Fees, bot.LongPositionCount, bot.ShortPositionCount);
}
else
{