Fix status and filtered positions for metrics

This commit is contained in:
2025-10-08 18:37:38 +07:00
parent 86dd6849ea
commit 76b087a6e4
8 changed files with 57 additions and 89 deletions

View File

@@ -169,7 +169,8 @@ public class AgentGrain : Grain, IAgentGrain
try
{
// Get all positions for this agent's bots as initiator
var positions = (await _tradingService.GetPositionByUserIdAsync((int)this.GetPrimaryKeyLong())).ToList();
var positions = (await _tradingService.GetPositionByUserIdAsync((int)this.GetPrimaryKeyLong()))
.Where(p => p.IsValidForMetrics()).ToList();
// Calculate aggregated statistics from position data
var totalPnL = positions.Sum(p => p.ProfitAndLoss?.Realized ?? 0);