Skip to content

Fix capacity snapshot selection for zero-capacity symbols#9415

Closed
aiSynergy37 wants to merge 1 commit intoQuantConnect:masterfrom
aiSynergy37:bug-6523-capacity-zero-volume-snapshot
Closed

Fix capacity snapshot selection for zero-capacity symbols#9415
aiSynergy37 wants to merge 1 commit intoQuantConnect:masterfrom
aiSynergy37:bug-6523-capacity-zero-volume-snapshot

Conversation

@aiSynergy37
Copy link
Copy Markdown
Contributor

Description

Fixes an edge case in CapacityEstimate.UpdateMarketCapacity where snapshot selection could pick a symbol with no valid market-capacity data (Trades == 0 or MarketCapacityDollarVolume == 0).

This could cause a stale/delisted zero-capacity symbol to drive snapshot logic and trigger unnecessary margin model calls.

Changes

  • Filter snapshot candidates to symbols with usable capacity inputs:
    • Trades > 0
    • MarketCapacityDollarVolume > 0
  • Use FirstOrDefault() for candidate selection and skip scaling logic when no valid candidate exists.
  • Preserve existing reset/removal housekeeping for symbol capacity entries.
  • Add regression test:
    • CapacityEstimateTests.UpdateMarketCapacitySkipsSymbolsWithoutMarketCapacityData
    • Verifies we do not query reserved buying power for symbols without market-capacity data.

Validation

  • dotnet build Tests/QuantConnect.Tests.csproj --no-restore -v minimal ✅
  • dotnet test Tests/QuantConnect.Tests.csproj --filter FullyQualifiedName~CapacityEstimateTests.UpdateMarketCapacitySkipsSymbolsWithoutMarketCapacityData --no-build -v normal -m:1 ⚠️
    • Test host aborts in this environment due Python.NET GIL finalizer crash:
      • System.InvalidOperationException: GIL must always be released...

Closes #6523

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.

Capacity estimate calculating buying power for FOPs after underlying's cache is reset

3 participants