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
})

View File

@@ -13,10 +13,15 @@ namespace Managing.Api.Models.Responses
public string AgentName { get; set; }
/// <summary>
/// Total profit and loss in USD
/// Total profit and loss in USD (gross, before fees)
/// </summary>
public decimal TotalPnL { get; set; }
/// <summary>
/// Net profit and loss in USD (after fees)
/// </summary>
public decimal NetPnL { get; set; }
/// <summary>
/// Total return on investment as a percentage
/// </summary>
@@ -160,10 +165,15 @@ namespace Managing.Api.Models.Responses
public required decimal TotalVolume { get; set; }
/// <summary>
/// Total PnL on this date in USD
/// Total PnL on this date in USD (gross, before fees)
/// </summary>
public required decimal TotalPnL { get; set; }
/// <summary>
/// Net PnL on this date in USD (after fees)
/// </summary>
public required decimal NetPnL { get; set; }
/// <summary>
/// Total open interest on this date in USD
/// </summary>

View File

@@ -50,7 +50,7 @@ public class PaginatedAgentIndexResponse
/// <summary>
/// Field used for sorting
/// </summary>
public SortableFields SortBy { get; set; } = SortableFields.TotalPnL;
public SortableFields SortBy { get; set; } = SortableFields.NetPnL;
/// <summary>
/// Sort order (asc or desc)

View File

@@ -11,10 +11,15 @@ namespace Managing.Api.Models.Responses
public string StrategyName { get; set; }
/// <summary>
/// Profit and Loss value of the strategy
/// Profit and Loss value of the strategy (gross, before fees)
/// </summary>
public decimal PnL { get; set; }
/// <summary>
/// Net Profit and Loss value of the strategy (after fees)
/// </summary>
public decimal NetPnL { get; set; }
public string AgentName { get; set; }
}
@@ -34,10 +39,15 @@ namespace Managing.Api.Models.Responses
public decimal Roi { get; set; }
/// <summary>
/// Profit and Loss value of the strategy
/// Profit and Loss value of the strategy (gross, before fees)
/// </summary>
public decimal PnL { get; set; }
/// <summary>
/// Net Profit and Loss value of the strategy (after fees)
/// </summary>
public decimal NetPnL { get; set; }
/// <summary>
/// Volume traded by the strategy
/// </summary>
@@ -77,10 +87,15 @@ namespace Managing.Api.Models.Responses
public string AgentName { get; set; }
/// <summary>
/// Profit and Loss value of the agent
/// Profit and Loss value of the agent (gross, before fees)
/// </summary>
public decimal PnL { get; set; }
/// <summary>
/// Net Profit and Loss value of the agent (after fees)
/// </summary>
public decimal NetPnL { get; set; }
/// <summary>
/// Total ROI percentage of the agent
/// </summary>

View File

@@ -19,10 +19,15 @@ namespace Managing.Api.Models.Responses
public Enums.BotStatus State { get; set; }
/// <summary>
/// Total profit or loss generated by the strategy in USD
/// Total profit or loss generated by the strategy in USD (gross, before fees)
/// </summary>
public decimal PnL { get; set; }
/// <summary>
/// Net profit or loss generated by the strategy in USD (after fees)
/// </summary>
public decimal NetPnL { get; set; }
/// <summary>
/// Return on investment percentage
/// </summary>