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);
|
||||
|
||||
@@ -42,6 +42,11 @@ namespace Managing.Api.Models.Responses
|
||||
/// Total volume traded by this agent in USD
|
||||
/// </summary>
|
||||
public decimal TotalVolume { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Total balance including USDC and open position values (without leverage, including PnL)
|
||||
/// </summary>
|
||||
public decimal TotalBalance { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -9,11 +9,13 @@ namespace Managing.Api.Models.Responses
|
||||
/// Name of the strategy bot
|
||||
/// </summary>
|
||||
public string StrategyName { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Profit and Loss value of the strategy
|
||||
/// </summary>
|
||||
public decimal PnL { get; set; }
|
||||
|
||||
public string AgentName { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -25,17 +27,17 @@ namespace Managing.Api.Models.Responses
|
||||
/// Name of the strategy bot
|
||||
/// </summary>
|
||||
public string StrategyName { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Return on Investment percentage of the strategy
|
||||
/// </summary>
|
||||
public decimal Roi { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Profit and Loss value of the strategy
|
||||
/// </summary>
|
||||
public decimal PnL { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Volume traded by the strategy
|
||||
/// </summary>
|
||||
@@ -52,7 +54,7 @@ namespace Managing.Api.Models.Responses
|
||||
/// </summary>
|
||||
public List<StrategyPerformance> TopStrategies { get; set; } = new List<StrategyPerformance>();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// View model containing the top performing strategies by ROI
|
||||
/// </summary>
|
||||
@@ -63,4 +65,4 @@ namespace Managing.Api.Models.Responses
|
||||
/// </summary>
|
||||
public List<StrategyRoiPerformance> TopStrategiesByRoi { get; set; } = new List<StrategyRoiPerformance>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user