Fix historic total positions

This commit is contained in:
2025-09-24 01:32:14 +07:00
parent 9bdfb989c1
commit b8dfb4f111

View File

@@ -55,11 +55,13 @@ public class PlatformSummaryGrain : Grain, IPlatformSummaryGrain, IRemindable
_logger.LogInformation("Daily reminder scheduled - Next daily: {NextDaily}", nextDailyTime); _logger.LogInformation("Daily reminder scheduled - Next daily: {NextDaily}", nextDailyTime);
// Initial data load if state is empty
if (_state.State.LastUpdated == default)
{
await RefreshDataAsync(); await RefreshDataAsync();
}
// // Initial data load if state is empty
// if (_state.State.LastUpdated == default)
// {
// await RefreshDataAsync();
// }
} }
public async Task<PlatformSummaryViewModel> GetPlatformSummaryAsync() public async Task<PlatformSummaryViewModel> GetPlatformSummaryAsync()
@@ -187,7 +189,7 @@ public class PlatformSummaryGrain : Grain, IPlatformSummaryGrain, IRemindable
if (openPositions?.Any() == true) if (openPositions?.Any() == true)
{ {
var positionCount = openPositions.Count(); var positionCount = allPositions.Count();
// Calculate open interest as the sum of leveraged position notional values // Calculate open interest as the sum of leveraged position notional values
// Open interest = sum of (position size * price * leverage) for all open positions // Open interest = sum of (position size * price * leverage) for all open positions
@@ -203,7 +205,7 @@ public class PlatformSummaryGrain : Grain, IPlatformSummaryGrain, IRemindable
else else
{ {
_logger.LogDebug("No open positions found for metrics calculation"); _logger.LogDebug("No open positions found for metrics calculation");
return (0m, 0); return (0m, allPositions.Count());
} }
} }
catch (Exception ex) catch (Exception ex)