Add volume history to platform summary
This commit is contained in:
@@ -35,7 +35,8 @@ public static class PlatformSummaryExtensions
|
|||||||
kvp => kvp.Key,
|
kvp => kvp.Key,
|
||||||
kvp => kvp.Value) ?? new Dictionary<Enums.TradeDirection, int>(),
|
kvp => kvp.Value) ?? new Dictionary<Enums.TradeDirection, int>(),
|
||||||
LastUpdated = abstractionsModel.LastUpdated,
|
LastUpdated = abstractionsModel.LastUpdated,
|
||||||
Last24HourSnapshot = abstractionsModel.Last24HourSnapshot
|
Last24HourSnapshot = abstractionsModel.Last24HourSnapshot,
|
||||||
|
VolumeHistory = abstractionsModel.VolumeHistory,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Managing.Application.Abstractions.Models;
|
||||||
using Managing.Common;
|
using Managing.Common;
|
||||||
|
|
||||||
namespace Managing.Api.Models.Responses
|
namespace Managing.Api.Models.Responses
|
||||||
@@ -146,6 +147,7 @@ namespace Managing.Api.Models.Responses
|
|||||||
/// When the last 24-hour snapshot was taken
|
/// When the last 24-hour snapshot was taken
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public required DateTime Last24HourSnapshot { get; set; }
|
public required DateTime Last24HourSnapshot { get; set; }
|
||||||
|
public List<VolumeHistoryPoint> VolumeHistory { get; internal set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ public interface IPlatformSummaryGrain : IGrainWithStringKey
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
Task<int> GetTotalPositionCountAsync();
|
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
|
// Event handlers for immediate updates
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the active strategy count
|
/// Updates the active strategy count
|
||||||
|
|||||||
@@ -130,3 +130,5 @@ public class DailySnapshot
|
|||||||
[Id(6)]
|
[Id(6)]
|
||||||
public int TotalPositionCount { get; set; }
|
public int TotalPositionCount { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -119,4 +119,29 @@ public class PlatformSummaryViewModel
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Id(17)]
|
[Id(17)]
|
||||||
public required DateTime Last24HourSnapshot { get; set; }
|
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);
|
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
|
// Event handlers for immediate updates
|
||||||
public async Task UpdateActiveStrategyCountAsync(int newActiveCount)
|
public async Task UpdateActiveStrategyCountAsync(int newActiveCount)
|
||||||
{
|
{
|
||||||
@@ -374,6 +388,16 @@ public class PlatformSummaryGrain : Grain, IPlatformSummaryGrain, IRemindable
|
|||||||
|
|
||||||
private PlatformSummaryViewModel MapToViewModel(PlatformSummaryGrainState state)
|
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
|
return new PlatformSummaryViewModel
|
||||||
{
|
{
|
||||||
TotalAgents = state.TotalAgents,
|
TotalAgents = state.TotalAgents,
|
||||||
@@ -397,6 +421,9 @@ public class PlatformSummaryGrain : Grain, IPlatformSummaryGrain, IRemindable
|
|||||||
PositionCountByAsset = state.PositionCountByAsset ?? new Dictionary<Ticker, int>(),
|
PositionCountByAsset = state.PositionCountByAsset ?? new Dictionary<Ticker, int>(),
|
||||||
PositionCountByDirection = state.PositionCountByDirection ?? new Dictionary<TradeDirection, int>(),
|
PositionCountByDirection = state.PositionCountByDirection ?? new Dictionary<TradeDirection, int>(),
|
||||||
|
|
||||||
|
// Volume history for charting (last 30 days)
|
||||||
|
VolumeHistory = volumeHistory,
|
||||||
|
|
||||||
// Metadata
|
// Metadata
|
||||||
LastUpdated = state.LastUpdated,
|
LastUpdated = state.LastUpdated,
|
||||||
Last24HourSnapshot = state.LastSnapshot
|
Last24HourSnapshot = state.LastSnapshot
|
||||||
|
|||||||
@@ -4588,6 +4588,7 @@ export interface TopStrategiesViewModel {
|
|||||||
export interface StrategyPerformance {
|
export interface StrategyPerformance {
|
||||||
strategyName?: string | null;
|
strategyName?: string | null;
|
||||||
pnL?: number;
|
pnL?: number;
|
||||||
|
agentName?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TopStrategiesByRoiViewModel {
|
export interface TopStrategiesByRoiViewModel {
|
||||||
@@ -4661,6 +4662,7 @@ export interface AgentSummaryViewModel {
|
|||||||
losses?: number;
|
losses?: number;
|
||||||
activeStrategiesCount?: number;
|
activeStrategiesCount?: number;
|
||||||
totalVolume?: number;
|
totalVolume?: number;
|
||||||
|
totalBalance?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum SortableFields {
|
export enum SortableFields {
|
||||||
|
|||||||
@@ -943,6 +943,7 @@ export interface TopStrategiesViewModel {
|
|||||||
export interface StrategyPerformance {
|
export interface StrategyPerformance {
|
||||||
strategyName?: string | null;
|
strategyName?: string | null;
|
||||||
pnL?: number;
|
pnL?: number;
|
||||||
|
agentName?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TopStrategiesByRoiViewModel {
|
export interface TopStrategiesByRoiViewModel {
|
||||||
@@ -1016,6 +1017,7 @@ export interface AgentSummaryViewModel {
|
|||||||
losses?: number;
|
losses?: number;
|
||||||
activeStrategiesCount?: number;
|
activeStrategiesCount?: number;
|
||||||
totalVolume?: number;
|
totalVolume?: number;
|
||||||
|
totalBalance?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum SortableFields {
|
export enum SortableFields {
|
||||||
|
|||||||
Reference in New Issue
Block a user