Add net Pnl in db

This commit is contained in:
2025-09-28 22:18:58 +07:00
parent 6267dad8fa
commit f041c1e8e8
28 changed files with 3095 additions and 54 deletions

View File

@@ -346,6 +346,7 @@ public class DataController : ControllerBase
{
StrategyName = bot.Name,
PnL = bot.Pnl,
NetPnL = bot.NetPnL,
AgentName = bot.User.AgentName,
})
.ToList()
@@ -373,6 +374,7 @@ public class DataController : ControllerBase
StrategyName = bot.Name,
Roi = bot.Roi,
PnL = bot.Pnl,
NetPnL = bot.NetPnL,
Volume = bot.Volume
})
.ToList()
@@ -393,10 +395,10 @@ public class DataController : ControllerBase
// Get all agent summaries
var allAgentSummaries = await _mediator.Send(new GetAllAgentSummariesCommand());
// Filter agents with valid PnL data and order by PnL
// Filter agents with valid PnL data and order by NetPnL
var agentsWithPnL = allAgentSummaries
.Where(agent => agent.TotalPnL != 0) // Only include agents with actual PnL
.OrderByDescending(agent => agent.TotalPnL)
.Where(agent => agent.NetPnL != 0) // Only include agents with actual NetPnL
.OrderByDescending(agent => agent.NetPnL)
.Take(3)
.ToList();
@@ -408,6 +410,7 @@ public class DataController : ControllerBase
{
AgentName = agent.AgentName,
PnL = agent.TotalPnL,
NetPnL = agent.NetPnL,
TotalROI = agent.TotalROI,
TotalVolume = agent.TotalVolume,
ActiveStrategiesCount = agent.ActiveStrategiesCount,
@@ -521,6 +524,7 @@ public class DataController : ControllerBase
Name = strategy.Name,
State = strategy.Status,
PnL = strategy.Pnl,
NetPnL = strategy.NetPnL,
ROIPercentage = strategy.Roi,
Runtime = strategy.StartupTime,
WinRate = winRate,
@@ -579,7 +583,7 @@ public class DataController : ControllerBase
public async Task<ActionResult<PaginatedAgentIndexResponse>> GetAgentIndexPaginated(
int page = 1,
int pageSize = 10,
SortableFields sortBy = SortableFields.TotalPnL,
SortableFields sortBy = SortableFields.NetPnL,
string sortOrder = "desc",
string? agentNames = null)
{
@@ -632,6 +636,7 @@ public class DataController : ControllerBase
{
AgentName = agentSummary.AgentName,
TotalPnL = agentSummary.TotalPnL,
NetPnL = agentSummary.NetPnL,
TotalROI = agentSummary.TotalROI,
Wins = agentSummary.Wins,
Losses = agentSummary.Losses,
@@ -799,6 +804,7 @@ public class DataController : ControllerBase
TotalStrategies = s.TotalStrategies,
TotalVolume = s.TotalVolume,
TotalPnL = s.TotalPnL,
NetPnL = s.NetPnL,
TotalOpenInterest = s.TotalOpenInterest,
TotalPositionCount = s.TotalLifetimePositionCount
})