diff --git a/src/Managing.Application.Abstractions/Models/PlatformSummaryViewModel.cs b/src/Managing.Application.Abstractions/Models/PlatformSummaryViewModel.cs index 86bfe60..05126f5 100644 --- a/src/Managing.Application.Abstractions/Models/PlatformSummaryViewModel.cs +++ b/src/Managing.Application.Abstractions/Models/PlatformSummaryViewModel.cs @@ -1,3 +1,4 @@ +using Orleans; using static Managing.Common.Enums; namespace Managing.Application.Abstractions.Models; @@ -5,98 +6,117 @@ namespace Managing.Application.Abstractions.Models; /// /// Platform-wide statistics without individual agent details /// +[GenerateSerializer] public class PlatformSummaryViewModel { /// /// Total number of agents on the platform /// + [Id(0)] public required int TotalAgents { get; set; } /// /// Total number of active strategies across all agents /// + [Id(1)] public required int TotalActiveStrategies { get; set; } /// /// Total platform-wide profit and loss in USD /// + [Id(2)] public required decimal TotalPlatformPnL { get; set; } /// /// Total volume traded across all agents in USD /// + [Id(3)] public required decimal TotalPlatformVolume { get; set; } /// /// Total volume traded across all agents in the last 24 hours in USD /// + [Id(4)] public required decimal TotalPlatformVolumeLast24h { get; set; } /// /// Total open interest across all positions in USD /// + [Id(5)] public required decimal TotalOpenInterest { get; set; } /// /// Total number of open positions across all strategies /// + [Id(6)] public required int TotalPositionCount { get; set; } // 24-hour changes /// /// Change in agent count over the last 24 hours /// + [Id(7)] public required int AgentsChange24h { get; set; } /// /// Change in strategy count over the last 24 hours /// + [Id(8)] public required int StrategiesChange24h { get; set; } /// /// Change in PnL over the last 24 hours /// + [Id(9)] public required decimal PnLChange24h { get; set; } /// /// Change in volume over the last 24 hours /// + [Id(10)] public required decimal VolumeChange24h { get; set; } /// /// Change in open interest over the last 24 hours /// + [Id(11)] public required decimal OpenInterestChange24h { get; set; } /// /// Change in position count over the last 24 hours /// + [Id(12)] public required int PositionCountChange24h { get; set; } // Breakdowns /// /// Volume breakdown by asset/ticker /// + [Id(13)] public required Dictionary VolumeByAsset { get; set; } /// /// Position count breakdown by asset/ticker /// + [Id(14)] public required Dictionary PositionCountByAsset { get; set; } /// /// Position count breakdown by direction (Long/Short) /// + [Id(15)] public required Dictionary PositionCountByDirection { get; set; } // Metadata /// /// When the data was last updated /// + [Id(16)] public required DateTime LastUpdated { get; set; } /// /// When the last 24-hour snapshot was taken /// + [Id(17)] public required DateTime Last24HourSnapshot { get; set; } } diff --git a/src/Managing.Bootstrap/ApiBootstrap.cs b/src/Managing.Bootstrap/ApiBootstrap.cs index 7246c53..f4296b3 100644 --- a/src/Managing.Bootstrap/ApiBootstrap.cs +++ b/src/Managing.Bootstrap/ApiBootstrap.cs @@ -148,6 +148,11 @@ public static class ApiBootstrap options.ConnectionString = postgreSqlConnectionString; options.Invariant = "Npgsql"; }) + .AddAdoNetGrainStorage("platform-summary-store", options => + { + options.ConnectionString = postgreSqlConnectionString; + options.Invariant = "Npgsql"; + }) .ConfigureServices(services => { // Register existing services for Orleans DI @@ -173,7 +178,7 @@ public static class ApiBootstrap services.AddScoped(); services.AddScoped(); services.AddScoped(); - services.AddSingleton(); + services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); diff --git a/src/Managing.Bootstrap/WorkersBootstrap.cs b/src/Managing.Bootstrap/WorkersBootstrap.cs index 917ab2f..bbfcfa8 100644 --- a/src/Managing.Bootstrap/WorkersBootstrap.cs +++ b/src/Managing.Bootstrap/WorkersBootstrap.cs @@ -58,7 +58,7 @@ public static class WorkersBootstrap services.AddScoped(); services.AddScoped(); services.AddScoped(); - services.AddSingleton(); + services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped();