Rename a bit for more clarity

This commit is contained in:
2025-09-28 14:18:56 +07:00
parent a8d09c36b7
commit 147186724e
3 changed files with 10 additions and 11 deletions

View File

@@ -785,7 +785,7 @@ public class DataController : ControllerBase
TotalPlatformPnL = state.TotalPlatformPnL,
TotalPlatformVolume = state.TotalPlatformVolume,
OpenInterest = state.OpenInterest,
TotalPositionCount = state.TotalPositionCount,
TotalPositionCount = state.TotalLifetimePositionCount,
TotalPlatformFees = state.TotalPlatformFees,
// Historical snapshots

View File

@@ -26,7 +26,7 @@ public class PlatformSummaryGrainState
[Id(7)] public decimal OpenInterest { get; set; }
[Id(8)] public int TotalPositionCount { get; set; }
[Id(8)] public int TotalLifetimePositionCount { get; set; }
[Id(9)] public decimal TotalPlatformFees { get; set; }

View File

@@ -133,7 +133,7 @@ public class PlatformSummaryGrain : Grain, IPlatformSummaryGrain, IRemindable
_state.State.TotalPlatformPnL = totalPnL;
_state.State.OpenInterest = totalOpenInterest;
_state.State.TotalPositionCount = totalPositionCount;
_state.State.TotalLifetimePositionCount = totalPositionCount;
_state.State.LastUpdated = DateTime.UtcNow;
_state.State.HasPendingChanges = false;
@@ -223,13 +223,12 @@ public class PlatformSummaryGrain : Grain, IPlatformSummaryGrain, IRemindable
{
// Get all open positions from all accounts
// Get positions directly from database instead of exchange
var allPositions = await _tradingService.GetAllDatabasePositionsAsync();
var allPositions = (await _tradingService.GetAllDatabasePositionsAsync()).ToList();
var openPositions = allPositions?.Where(p => !p.IsFinished());
var totalOpenPositionCount = allPositions.Count();
if (openPositions?.Any() == true)
if (openPositions.Any())
{
var positionCount = allPositions.Count();
// Calculate open interest as the sum of leveraged position notional values
// Open interest = sum of (position size * price * leverage) for all open positions
var openInterest = openPositions
@@ -237,9 +236,9 @@ public class PlatformSummaryGrain : Grain, IPlatformSummaryGrain, IRemindable
_logger.LogDebug(
"Calculated position metrics: {PositionCount} positions, {OpenInterest} leveraged open interest",
positionCount, openInterest);
totalOpenPositionCount, openInterest);
return (openInterest, positionCount);
return (openInterest, totalOpenPositionCount);
}
else
{
@@ -354,7 +353,7 @@ public class PlatformSummaryGrain : Grain, IPlatformSummaryGrain, IRemindable
// Update open interest and position count
// Since this is called only when position is fully open on broker, we always increase counts
_state.State.TotalPositionCount++;
_state.State.TotalLifetimePositionCount++;
_state.State.OpenInterest += evt.Volume;
// Update position count by asset
@@ -414,7 +413,7 @@ public class PlatformSummaryGrain : Grain, IPlatformSummaryGrain, IRemindable
TotalVolume = _state.State.TotalPlatformVolume,
TotalPnL = _state.State.TotalPlatformPnL,
TotalOpenInterest = _state.State.OpenInterest,
TotalPositionCount = _state.State.TotalPositionCount,
TotalPositionCount = _state.State.TotalLifetimePositionCount,
};
_state.State.DailySnapshots.Add(dailySnapshot);