Fix loss and win count for GetUserStrategy
This commit is contained in:
@@ -498,9 +498,10 @@ public class DataController : ControllerBase
|
|||||||
_cacheService.SaveValue(cacheKey, positions, TimeSpan.FromMinutes(2));
|
_cacheService.SaveValue(cacheKey, positions, TimeSpan.FromMinutes(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var positionsForMetrics = positions.Where(p => p.IsValidForMetrics());
|
||||||
// Calculate win/loss statistics from actual positions (including open positions)
|
// Calculate win/loss statistics from actual positions (including open positions)
|
||||||
int wins = positions.Count(p => p.ProfitAndLoss != null && p.ProfitAndLoss.Realized > 0);
|
int wins = positionsForMetrics.Count(p => p.ProfitAndLoss != null && p.ProfitAndLoss.Realized > 0);
|
||||||
int losses = positions.Count(p => p.ProfitAndLoss != null && p.ProfitAndLoss.Realized <= 0);
|
int losses = positionsForMetrics.Count(p => p.ProfitAndLoss != null && p.ProfitAndLoss.Realized <= 0);
|
||||||
|
|
||||||
int winRate = wins + losses > 0 ? (wins * 100) / (wins + losses) : 0;
|
int winRate = wins + losses > 0 ? (wins * 100) / (wins + losses) : 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user