Skip to content

Retain live statistics samples through chart trimming#9491

Open
stoicAI1776 wants to merge 1 commit into
QuantConnect:masterfrom
stoicAI1776:bug-9477-live-statistics-retention
Open

Retain live statistics samples through chart trimming#9491
stoicAI1776 wants to merge 1 commit into
QuantConnect:masterfrom
stoicAI1776:bug-9477-live-statistics-retention

Conversation

@stoicAI1776
Copy link
Copy Markdown
Contributor

Description

Fixes #9477.

Live chart trimming keeps streamed/displayed charts bounded to the recent window, but statistics were generated from those same trimmed series. After a few days, daily Return and Benchmark samples could be trimmed down to too few points, causing PSR and related live-mode risk metrics to collapse to defaults.

This change keeps a small live-only retention buffer for the daily statistics inputs and merges those retained samples into the chart clones used for statistics generation. The visible/live chart trimming path remains unchanged.

Changes

  • Made BaseResultsHandler.GenerateStatisticsResults(Dictionary<string, Chart>, ...) virtual so live results can prepare statistics inputs before delegating.
  • Retain daily live samples for:
    • Strategy Equity / Equity
    • Strategy Equity / Return
    • Benchmark / Benchmark
    • Portfolio Turnover / Portfolio Turnover
  • Merge retained samples into the cloned charts used for statistics, deduplicating by timestamp.
  • Added coverage that simulates chart trimming and verifies statistics samples are restored before generation.

Testing

  • git diff --check
  • Attempted: dotnet test Tests\QuantConnect.Tests.csproj --filter RetainsDailyStatisticsSamplesAfterChartTrimming --no-restore --logger "console;verbosity=minimal"
  • Attempted: dotnet build Tests\QuantConnect.Tests.csproj --no-restore -v:minimal /m:1 /nr:false
  • Result: both local .NET commands hung during startup/build without compiler or fixture output and were terminated after timeout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PSR (and other risk metrics) stay at 0% in live mode due to chart trimming

1 participant