Refactor LiveBotRegistryGrain and PlatformSummaryGrain to improve active bot tracking

- Introduced CalculateActiveBotsCount method in LiveBotRegistryGrain to streamline active bot count calculations.
- Updated logging to reflect active bot counts accurately during registration and unregistration.
- Added historical tracking of strategy activation/deactivation events in PlatformSummaryGrain, including a new StrategyEvent class and related logic to manage event history.
- Enhanced CalculateActiveStrategiesForDate method to compute active strategies based on historical events.
This commit is contained in:
2025-11-21 19:38:32 +07:00
parent eac13dd5e4
commit 153e170ca4
3 changed files with 106 additions and 27 deletions

View File

@@ -45,6 +45,29 @@ public class PlatformSummaryGrainState
// Flag to track if volume has been updated by events (not from bot strategies)
[Id(15)] public bool VolumeUpdatedByEvents { get; set; }
// Historical strategy activation/deactivation events
[Id(16)] public List<StrategyEvent> StrategyEvents { get; set; } = new();
}
/// <summary>
/// Strategy activation/deactivation event
/// </summary>
[GenerateSerializer]
public class StrategyEvent
{
[Id(0)] public DateTime Timestamp { get; set; }
[Id(1)] public StrategyEventType EventType { get; set; }
[Id(2)] public int NetChange { get; set; } // +1 for activation, -1 for deactivation
}
/// <summary>
/// Type of strategy event
/// </summary>
public enum StrategyEventType
{
Activation,
Deactivation
}
/// <summary>