Fix global pnl

This commit is contained in:
2025-09-26 12:21:32 +07:00
parent 1e19e29cec
commit 6d3b706b3e

View File

@@ -515,10 +515,11 @@ public class PostgreSqlTradingRepository : ITradingRepository
// Calculate total PnL from all finished positions (closed positions)
// Only include positions that are Finished or Flipped (closed positions)
// Include UiFees and GasFees in the calculation for accurate net PnL
var totalPnL = await _context.Positions
.AsNoTracking()
.Where(p => p.Status == PositionStatus.Finished || p.Status == PositionStatus.Flipped)
.SumAsync(p => p.ProfitAndLoss)
.SumAsync(p => p.ProfitAndLoss - p.UiFees - p.GasFees)
.ConfigureAwait(false);
return totalPnL;