Add agentbalance
This commit is contained in:
@@ -345,7 +345,7 @@ public class DataController : ControllerBase
|
||||
|
||||
// Calculate PnL for each bot once and store in a list of tuples
|
||||
var botsWithPnL = activeBots
|
||||
.Select(bot => new { Bot = bot, PnL = bot.Pnl })
|
||||
.Select(bot => new { Bot = bot, PnL = bot.Pnl, agentName = bot.User.AgentName })
|
||||
.OrderByDescending(item => item.PnL)
|
||||
.Take(3)
|
||||
.ToList();
|
||||
@@ -357,7 +357,8 @@ public class DataController : ControllerBase
|
||||
.Select(item => new StrategyPerformance
|
||||
{
|
||||
StrategyName = item.Bot.Name,
|
||||
PnL = item.PnL
|
||||
PnL = item.PnL,
|
||||
AgentName = item.agentName,
|
||||
})
|
||||
.ToList()
|
||||
};
|
||||
@@ -452,7 +453,8 @@ public class DataController : ControllerBase
|
||||
/// <param name="strategy">The trading bot to map</param>
|
||||
/// <param name="positionsByIdentifier">Pre-fetched positions grouped by initiator identifier</param>
|
||||
/// <returns>A view model with detailed strategy information</returns>
|
||||
private UserStrategyDetailsViewModel MapStrategyToViewModel(Bot strategy, Dictionary<Guid, List<Position>> positionsByIdentifier)
|
||||
private UserStrategyDetailsViewModel MapStrategyToViewModel(Bot strategy,
|
||||
Dictionary<Guid, List<Position>> positionsByIdentifier)
|
||||
{
|
||||
// Calculate ROI percentage based on PnL relative to account value
|
||||
decimal pnl = strategy.Pnl;
|
||||
@@ -473,8 +475,8 @@ public class DataController : ControllerBase
|
||||
decimal roiLast24h = strategy.Roi;
|
||||
|
||||
// Get positions for this strategy from pre-fetched data
|
||||
var positions = positionsByIdentifier.TryGetValue(strategy.Identifier, out var strategyPositions)
|
||||
? strategyPositions
|
||||
var positions = positionsByIdentifier.TryGetValue(strategy.Identifier, out var strategyPositions)
|
||||
? strategyPositions
|
||||
: new List<Position>();
|
||||
|
||||
return new UserStrategyDetailsViewModel
|
||||
@@ -645,6 +647,7 @@ public class DataController : ControllerBase
|
||||
Losses = agentSummary.Losses,
|
||||
ActiveStrategiesCount = agentSummary.ActiveStrategiesCount,
|
||||
TotalVolume = agentSummary.TotalVolume,
|
||||
TotalBalance = agentSummary.TotalBalance,
|
||||
};
|
||||
|
||||
agentSummaryViewModels.Add(agentSummaryViewModel);
|
||||
|
||||
Reference in New Issue
Block a user