Fix ROI calculation for Strategy

This commit is contained in:
2025-10-08 19:37:24 +07:00
parent 76b087a6e4
commit 1a99224d18
5 changed files with 41 additions and 36 deletions

View File

@@ -142,13 +142,6 @@ public class PlatformSummaryGrain : Grain, IPlatformSummaryGrain, IRemindable
var positionVolume = TradingHelpers.GetVolumeForPosition(position);
totalVolume += positionVolume;
// Add to open interest for active positions only (only opening volume)
if (position.Status.Equals(PositionStatus.Filled))
{
var openingVolume = position.Open.Price * position.Open.Quantity * position.Open.Leverage;
totalOpenInterest += openingVolume;
}
// Calculate fees and PnL for all positions
totalFees += position.CalculateTotalFees();
totalPnL += position.ProfitAndLoss?.Realized ?? 0;
@@ -177,8 +170,11 @@ public class PlatformSummaryGrain : Grain, IPlatformSummaryGrain, IRemindable
_state.State.PositionCountByAsset[ticker]++;
// Position count breakdown by direction - only count finished positions
if (position.IsValidForMetrics())
if (position.IsOpen())
{
var openingVolume = position.Open.Price * position.Open.Quantity * position.Open.Leverage;
totalOpenInterest += openingVolume;
if (!_state.State.PositionCountByDirection.ContainsKey(direction))
{
_state.State.PositionCountByDirection[direction] = 0;