Fix dailySnapshot for platformsummary

This commit is contained in:
2025-09-24 12:21:56 +07:00
parent 44846a1817
commit d2a4bd4426
11 changed files with 241 additions and 397 deletions

View File

@@ -1,4 +1,3 @@
using Managing.Application.Abstractions.Models;
using Orleans;
using Orleans.Concurrency;
using static Managing.Common.Enums;
@@ -13,7 +12,7 @@ public interface IPlatformSummaryGrain : IGrainWithStringKey
/// <summary>
/// Gets the current platform summary data
/// </summary>
Task<PlatformSummaryViewModel> GetPlatformSummaryAsync();
Task<PlatformSummaryGrainState> GetPlatformSummaryAsync();
/// <summary>
/// Forces a refresh of all platform data
@@ -45,11 +44,6 @@ public interface IPlatformSummaryGrain : IGrainWithStringKey
/// </summary>
Task<decimal> GetTotalFeesAsync();
/// <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

View File

@@ -28,33 +28,18 @@ public class PlatformSummaryGrainState
[Id(8)] public int TotalPositionCount { get; set; }
[Id(20)] public decimal TotalPlatformFees { get; set; }
// 24-hour ago values (for comparison)
[Id(9)] public int TotalAgents24hAgo { get; set; }
[Id(10)] public int TotalActiveStrategies24hAgo { get; set; }
[Id(11)] public decimal TotalPlatformPnL24hAgo { get; set; }
[Id(12)] public decimal TotalPlatformVolume24hAgo { get; set; }
[Id(13)] public decimal TotalOpenInterest24hAgo { get; set; }
[Id(14)] public int TotalPositionCount24hAgo { get; set; }
[Id(21)] public decimal TotalPlatformFees24hAgo { get; set; }
[Id(9)] public decimal TotalPlatformFees { get; set; }
// Historical snapshots
[Id(15)] public List<DailySnapshot> DailySnapshots { get; set; } = new();
[Id(10)] public List<DailySnapshot> DailySnapshots { get; set; } = new();
// Volume breakdown by asset
[Id(16)] public Dictionary<Ticker, decimal> VolumeByAsset { get; set; } = new();
[Id(11)] public Dictionary<Ticker, decimal> VolumeByAsset { get; set; } = new();
// Position count breakdown
[Id(17)] public Dictionary<Ticker, int> PositionCountByAsset { get; set; } = new();
[Id(12)] public Dictionary<Ticker, int> PositionCountByAsset { get; set; } = new();
[Id(18)] public Dictionary<TradeDirection, int> PositionCountByDirection { get; set; } = new();
[Id(13)] public Dictionary<TradeDirection, int> PositionCountByDirection { get; set; } = new();
}
/// <summary>
@@ -76,6 +61,4 @@ public class DailySnapshot
[Id(5)] public decimal TotalOpenInterest { get; set; }
[Id(6)] public int TotalPositionCount { get; set; }
[Id(7)] public decimal TotalFees { get; set; }
}

View File

@@ -1,159 +0,0 @@
using Orleans;
using static Managing.Common.Enums;
namespace Managing.Application.Abstractions.Models;
/// <summary>
/// Platform-wide statistics without individual agent details
/// </summary>
[GenerateSerializer]
public class PlatformSummaryViewModel
{
/// <summary>
/// Total number of agents on the platform
/// </summary>
[Id(0)]
public required int TotalAgents { get; set; }
/// <summary>
/// Total number of active strategies across all agents
/// </summary>
[Id(1)]
public required int TotalActiveStrategies { get; set; }
/// <summary>
/// Total platform-wide profit and loss in USD
/// </summary>
[Id(2)]
public required decimal TotalPlatformPnL { get; set; }
/// <summary>
/// Total volume traded across all agents in USD
/// </summary>
[Id(3)]
public required decimal TotalPlatformVolume { get; set; }
/// <summary>
/// Total volume traded across all agents in the last 24 hours in USD
/// </summary>
[Id(4)]
public required decimal TotalPlatformVolumeLast24h { get; set; }
/// <summary>
/// Total open interest across all positions in USD
/// </summary>
[Id(5)]
public required decimal TotalOpenInterest { get; set; }
/// <summary>
/// Total number of open positions across all strategies
/// </summary>
[Id(6)]
public required int TotalPositionCount { get; set; }
/// <summary>
/// Total platform-wide fees paid in USD
/// </summary>
[Id(19)]
public required decimal TotalPlatformFees { get; set; }
// 24-hour changes
/// <summary>
/// Change in agent count over the last 24 hours
/// </summary>
[Id(7)]
public required int AgentsChange24h { get; set; }
/// <summary>
/// Change in strategy count over the last 24 hours
/// </summary>
[Id(8)]
public required int StrategiesChange24h { get; set; }
/// <summary>
/// Change in PnL over the last 24 hours
/// </summary>
[Id(9)]
public required decimal PnLChange24h { get; set; }
/// <summary>
/// Change in volume over the last 24 hours
/// </summary>
[Id(10)]
public required decimal VolumeChange24h { get; set; }
/// <summary>
/// Change in open interest over the last 24 hours
/// </summary>
[Id(11)]
public required decimal OpenInterestChange24h { get; set; }
/// <summary>
/// Change in position count over the last 24 hours
/// </summary>
[Id(12)]
public required int PositionCountChange24h { get; set; }
/// <summary>
/// Change in fees over the last 24 hours
/// </summary>
[Id(20)]
public required decimal FeesChange24h { get; set; }
// Breakdowns
/// <summary>
/// Volume breakdown by asset/ticker
/// </summary>
[Id(13)]
public required Dictionary<Ticker, decimal> VolumeByAsset { get; set; }
/// <summary>
/// Position count breakdown by asset/ticker
/// </summary>
[Id(14)]
public required Dictionary<Ticker, int> PositionCountByAsset { get; set; }
/// <summary>
/// Position count breakdown by direction (Long/Short)
/// </summary>
[Id(15)]
public required Dictionary<TradeDirection, int> PositionCountByDirection { get; set; }
// Metadata
/// <summary>
/// When the data was last updated
/// </summary>
[Id(16)]
public required DateTime LastUpdated { get; set; }
/// <summary>
/// When the last 24-hour snapshot was taken
/// </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; }
}