Fix global pnl
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user