Add volume history to platform summary

This commit is contained in:
2025-08-15 21:27:07 +07:00
parent 4292e9e02f
commit b4f6dc871b
8 changed files with 67 additions and 1 deletions

View File

@@ -229,6 +229,20 @@ public class PlatformSummaryGrain : Grain, IPlatformSummaryGrain, IRemindable
return Task.FromResult(_state.State.TotalPositionCount);
}
public Task<List<VolumeHistoryPoint>> GetVolumeHistoryAsync()
{
var historyPoints = _state.State.DailySnapshots
.OrderBy(s => s.Date)
.Select(s => new VolumeHistoryPoint
{
Date = s.Date,
Volume = s.TotalVolume
})
.ToList();
return Task.FromResult(historyPoints);
}
// Event handlers for immediate updates
public async Task UpdateActiveStrategyCountAsync(int newActiveCount)
{
@@ -374,6 +388,16 @@ public class PlatformSummaryGrain : Grain, IPlatformSummaryGrain, IRemindable
private PlatformSummaryViewModel MapToViewModel(PlatformSummaryGrainState state)
{
// Generate volume history from daily snapshots
var volumeHistory = state.DailySnapshots
.OrderBy(s => s.Date)
.Select(s => new VolumeHistoryPoint
{
Date = s.Date,
Volume = s.TotalVolume
})
.ToList();
return new PlatformSummaryViewModel
{
TotalAgents = state.TotalAgents,
@@ -397,6 +421,9 @@ public class PlatformSummaryGrain : Grain, IPlatformSummaryGrain, IRemindable
PositionCountByAsset = state.PositionCountByAsset ?? new Dictionary<Ticker, int>(),
PositionCountByDirection = state.PositionCountByDirection ?? new Dictionary<TradeDirection, int>(),
// Volume history for charting (last 30 days)
VolumeHistory = volumeHistory,
// Metadata
LastUpdated = state.LastUpdated,
Last24HourSnapshot = state.LastSnapshot