Rename a bit for more clarity
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user