diff --git a/src/Managing.Application/Grains/PlatformSummaryGrain.cs b/src/Managing.Application/Grains/PlatformSummaryGrain.cs index 6610827d..45f78e13 100644 --- a/src/Managing.Application/Grains/PlatformSummaryGrain.cs +++ b/src/Managing.Application/Grains/PlatformSummaryGrain.cs @@ -250,35 +250,6 @@ public class PlatformSummaryGrain : Grain, IPlatformSummaryGrain, IRemindable _logger.LogInformation("Position closed: {PositionId} for {Ticker} with PnL: {PnL}", evt.PositionIdentifier, evt.Ticker, evt.RealizedPnL); - // // Validate event data - // if (evt == null || evt.PositionIdentifier == Guid.Empty || evt.Ticker == Ticker.Unknown) - // { - // _logger.LogWarning("Invalid PositionClosedEvent received: {Event}", evt); - // return; - // } - - // _state.State.TotalPlatformVolume += evt.Volume; - - // // PnL is now calculated directly from database positions, not from events - // // This ensures accuracy and prevents double-counting issues - // // Refresh PnL from database to get the latest accurate value - // await RefreshPnLFromDatabaseAsync(); - - // // Update volume by asset - // var asset = evt.Ticker; - // if (!_state.State.VolumeByAsset.ContainsKey(asset)) - // { - // _state.State.VolumeByAsset[asset] = 0; - // } - - // _state.State.VolumeByAsset[asset] += evt.Volume; - - // // Mark that volume has been updated by events - // _state.State.VolumeUpdatedByEvents = true; - - // // Update open interest (subtract the closed position's volume) - // _state.State.OpenInterest = Math.Max(0, _state.State.OpenInterest - evt.Volume); - _state.State.HasPendingChanges = true; await _state.WriteStateAsync(); } @@ -295,55 +266,6 @@ public class PlatformSummaryGrain : Grain, IPlatformSummaryGrain, IRemindable _logger.LogInformation("Position opened: {PositionIdentifier} for {Ticker} with volume: {Volume}", evt.PositionIdentifier, evt.Ticker, evt.Volume); - // // Validate event data - // if (evt == null || evt.Ticker == Ticker.Unknown || evt.Volume <= 0) - // { - // _logger.LogWarning("Invalid PositionOpenEvent received: {Event}", evt); - // return; - // } - - // // Update platform volume - // _state.State.TotalPlatformVolume += evt.Volume; - - // // Update volume by asset - // var asset = evt.Ticker; - // if (!_state.State.VolumeByAsset.ContainsKey(asset)) - // { - // _state.State.VolumeByAsset[asset] = 0; - // } - - // _state.State.VolumeByAsset[asset] += evt.Volume; - - // // Mark that volume has been updated by events - // _state.State.VolumeUpdatedByEvents = true; - - // // Update open interest and position count - // // Since this is called only when position is fully open on broker, we always increase counts - // _state.State.TotalLifetimePositionCount++; - // _state.State.OpenInterest += evt.Volume; - - // // Update position count by asset - // if (!_state.State.PositionCountByAsset.ContainsKey(asset)) - // { - // _state.State.PositionCountByAsset[asset] = 0; - // } - - // _state.State.PositionCountByAsset[asset]++; - - // // Update position count by direction - // if (!_state.State.PositionCountByDirection.ContainsKey(evt.Direction)) - // { - // _state.State.PositionCountByDirection[evt.Direction] = 0; - // } - - // _state.State.PositionCountByDirection[evt.Direction]++; - - // // Update fees if provided - // if (evt.Fee > 0) - // { - // _state.State.TotalPlatformFees += evt.Fee; - // } - _state.State.HasPendingChanges = true; await _state.WriteStateAsync(); }