Add test and max collateral used

This commit is contained in:
2025-11-20 15:38:27 +07:00
parent 55f70add44
commit b1aa0541e2
2 changed files with 159 additions and 1 deletions

View File

@@ -601,7 +601,7 @@ public static class TradingBox
var totalVolume = GetTotalVolumeTraded(validPositions);
var wins = validPositions.Count(p => (p.ProfitAndLoss?.Net ?? 0m) > 0m);
var losses = validPositions.Count(p => (p.ProfitAndLoss?.Net ?? 0m) <= 0m);
var collateral = validPositions.Sum(p => (p.Open?.Price ?? 0m) * (p.Open?.Quantity ?? 0m));
var collateral = validPositions.Max(p => (p.Open?.Price ?? 0m) * (p.Open?.Quantity ?? 0m));
var totalROI = collateral > 0m ? (netPnL / collateral) * 100m : 0m;
return new AgentSummaryMetrics(totalPnL, netPnL, totalROI, totalVolume, wins, losses, totalFees,