Improve Platform stats
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Managing.Application.Abstractions.Models;
|
||||
using Orleans;
|
||||
using Orleans.Concurrency;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
namespace Managing.Application.Abstractions.Grains;
|
||||
@@ -39,6 +40,11 @@ public interface IPlatformSummaryGrain : IGrainWithStringKey
|
||||
/// </summary>
|
||||
Task<int> GetTotalPositionCountAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total platform fees
|
||||
/// </summary>
|
||||
Task<decimal> GetTotalFeesAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the daily volume history for the last 30 days for chart visualization
|
||||
/// </summary>
|
||||
@@ -48,9 +54,11 @@ public interface IPlatformSummaryGrain : IGrainWithStringKey
|
||||
/// <summary>
|
||||
/// Updates the active strategy count
|
||||
/// </summary>
|
||||
[OneWay]
|
||||
Task UpdateActiveStrategyCountAsync(int newActiveCount);
|
||||
Task OnPositionOpenedAsync(PositionOpenedEvent evt);
|
||||
[OneWay]
|
||||
Task OnPositionClosedAsync(PositionClosedEvent evt);
|
||||
[OneWay]
|
||||
Task OnTradeExecutedAsync(TradeExecutedEvent evt);
|
||||
}
|
||||
|
||||
@@ -66,24 +74,6 @@ public abstract class PlatformMetricsEvent
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when a new position is opened
|
||||
/// </summary>
|
||||
[GenerateSerializer]
|
||||
public class PositionOpenedEvent : PlatformMetricsEvent
|
||||
{
|
||||
[Id(1)]
|
||||
public Guid PositionId { get; set; }
|
||||
|
||||
[Id(2)]
|
||||
public Ticker Ticker { get; set; }
|
||||
|
||||
[Id(3)]
|
||||
public decimal Volume { get; set; }
|
||||
|
||||
[Id(4)]
|
||||
public TradeDirection Direction { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when a position is closed
|
||||
@@ -102,9 +92,6 @@ public class PositionClosedEvent : PlatformMetricsEvent
|
||||
|
||||
[Id(4)]
|
||||
public decimal Volume { get; set; }
|
||||
|
||||
[Id(5)]
|
||||
public decimal InitialVolume { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -37,6 +37,9 @@ 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; }
|
||||
@@ -56,52 +59,25 @@ public class PlatformSummaryGrainState
|
||||
[Id(14)]
|
||||
public int TotalPositionCount24hAgo { get; set; }
|
||||
|
||||
[Id(21)]
|
||||
public decimal TotalPlatformFees24hAgo { get; set; }
|
||||
|
||||
// Historical snapshots
|
||||
[Id(15)]
|
||||
public List<HourlySnapshot> HourlySnapshots { get; set; } = new();
|
||||
|
||||
[Id(16)]
|
||||
public List<DailySnapshot> DailySnapshots { get; set; } = new();
|
||||
|
||||
// Volume breakdown by asset
|
||||
[Id(17)]
|
||||
[Id(16)]
|
||||
public Dictionary<Ticker, decimal> VolumeByAsset { get; set; } = new();
|
||||
|
||||
// Position count breakdown
|
||||
[Id(18)]
|
||||
[Id(17)]
|
||||
public Dictionary<Ticker, int> PositionCountByAsset { get; set; } = new();
|
||||
|
||||
[Id(19)]
|
||||
[Id(18)]
|
||||
public Dictionary<TradeDirection, int> PositionCountByDirection { get; set; } = new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hourly snapshot of platform metrics
|
||||
/// </summary>
|
||||
[GenerateSerializer]
|
||||
public class HourlySnapshot
|
||||
{
|
||||
[Id(0)]
|
||||
public DateTime Timestamp { get; set; }
|
||||
|
||||
[Id(1)]
|
||||
public int TotalAgents { get; set; }
|
||||
|
||||
[Id(2)]
|
||||
public int TotalStrategies { get; set; }
|
||||
|
||||
[Id(3)]
|
||||
public decimal TotalVolume { get; set; }
|
||||
|
||||
[Id(4)]
|
||||
public decimal TotalPnL { get; set; }
|
||||
|
||||
[Id(5)]
|
||||
public decimal TotalOpenInterest { get; set; }
|
||||
|
||||
[Id(6)]
|
||||
public int TotalPositionCount { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Daily snapshot of platform metrics
|
||||
@@ -129,6 +105,9 @@ public class DailySnapshot
|
||||
|
||||
[Id(6)]
|
||||
public int TotalPositionCount { get; set; }
|
||||
|
||||
[Id(7)]
|
||||
public decimal TotalFees { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -51,6 +51,12 @@ public class PlatformSummaryViewModel
|
||||
[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
|
||||
@@ -88,6 +94,12 @@ public class PlatformSummaryViewModel
|
||||
[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
|
||||
|
||||
Reference in New Issue
Block a user