Add volume history to platform summary
This commit is contained in:
@@ -35,7 +35,8 @@ public static class PlatformSummaryExtensions
|
||||
kvp => kvp.Key,
|
||||
kvp => kvp.Value) ?? new Dictionary<Enums.TradeDirection, int>(),
|
||||
LastUpdated = abstractionsModel.LastUpdated,
|
||||
Last24HourSnapshot = abstractionsModel.Last24HourSnapshot
|
||||
Last24HourSnapshot = abstractionsModel.Last24HourSnapshot,
|
||||
VolumeHistory = abstractionsModel.VolumeHistory,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using Managing.Application.Abstractions.Models;
|
||||
using Managing.Common;
|
||||
|
||||
namespace Managing.Api.Models.Responses
|
||||
@@ -146,6 +147,7 @@ namespace Managing.Api.Models.Responses
|
||||
/// When the last 24-hour snapshot was taken
|
||||
/// </summary>
|
||||
public required DateTime Last24HourSnapshot { get; set; }
|
||||
public List<VolumeHistoryPoint> VolumeHistory { get; internal set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -39,6 +39,11 @@ public interface IPlatformSummaryGrain : IGrainWithStringKey
|
||||
/// </summary>
|
||||
Task<int> GetTotalPositionCountAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the daily volume history for the last 30 days for chart visualization
|
||||
/// </summary>
|
||||
Task<List<VolumeHistoryPoint>> GetVolumeHistoryAsync();
|
||||
|
||||
// Event handlers for immediate updates
|
||||
/// <summary>
|
||||
/// Updates the active strategy count
|
||||
|
||||
@@ -130,3 +130,5 @@ public class DailySnapshot
|
||||
[Id(6)]
|
||||
public int TotalPositionCount { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -119,4 +119,29 @@ public class PlatformSummaryViewModel
|
||||
/// </summary>
|
||||
[Id(17)]
|
||||
public required DateTime Last24HourSnapshot { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Daily volume history for the last 30 days for chart visualization
|
||||
/// </summary>
|
||||
[Id(18)]
|
||||
public required List<VolumeHistoryPoint> VolumeHistory { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a volume data point for historical charting
|
||||
/// </summary>
|
||||
[GenerateSerializer]
|
||||
public class VolumeHistoryPoint
|
||||
{
|
||||
/// <summary>
|
||||
/// Date of the volume measurement
|
||||
/// </summary>
|
||||
[Id(0)]
|
||||
public required DateTime Date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Total volume for that date in USD
|
||||
/// </summary>
|
||||
[Id(1)]
|
||||
public required decimal Volume { get; set; }
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -4588,6 +4588,7 @@ export interface TopStrategiesViewModel {
|
||||
export interface StrategyPerformance {
|
||||
strategyName?: string | null;
|
||||
pnL?: number;
|
||||
agentName?: string | null;
|
||||
}
|
||||
|
||||
export interface TopStrategiesByRoiViewModel {
|
||||
@@ -4661,6 +4662,7 @@ export interface AgentSummaryViewModel {
|
||||
losses?: number;
|
||||
activeStrategiesCount?: number;
|
||||
totalVolume?: number;
|
||||
totalBalance?: number;
|
||||
}
|
||||
|
||||
export enum SortableFields {
|
||||
|
||||
@@ -943,6 +943,7 @@ export interface TopStrategiesViewModel {
|
||||
export interface StrategyPerformance {
|
||||
strategyName?: string | null;
|
||||
pnL?: number;
|
||||
agentName?: string | null;
|
||||
}
|
||||
|
||||
export interface TopStrategiesByRoiViewModel {
|
||||
@@ -1016,6 +1017,7 @@ export interface AgentSummaryViewModel {
|
||||
losses?: number;
|
||||
activeStrategiesCount?: number;
|
||||
totalVolume?: number;
|
||||
totalBalance?: number;
|
||||
}
|
||||
|
||||
export enum SortableFields {
|
||||
|
||||
Reference in New Issue
Block a user