Skip to content

fix fills wait for fresh data on internal-only coarse subscriptions - #9836

Open
Tyagiquamar wants to merge 1 commit into
QuantConnect:masterfrom
Tyagiquamar:bug-9827-daily-future-stale-fill
Open

Tyagiquamar wants to merge 1 commit into
QuantConnect:masterfrom
Tyagiquamar:bug-9827-daily-future-stale-fill

Conversation

@Tyagiquamar

@Tyagiquamar Tyagiquamar commented Sep 26, 2026 •

Copy link
Copy Markdown

Problem

A daily continuous-future market order fills immediately at the stale previous close Tue-Fri with a stale-price warning, instead of waiting for fresh data. AddFuture("MNQ", Resolution.Daily) + MarketOrder(future.Mapped) at 12:30 fills at the prior 17:00 close (19.5h stale). On Mondays (67.5h gap) it correctly waits, and with SetFilter(0, 90) it always waits, which points at the wait-condition rather than data.

Root cause

In Common/Orders/Fills/FillModel.cs, ShouldWaitForFreshData only lets non-internal subscriptions decide whether all subscribed resolutions are coarse, and returns hasNonInternal. The mapped contract of a continuous future is internal-only by construction (ContinuousContractUniverse.GetSubscriptionRequests marks mapped configs internal), so the method returns false and the order never waits. The 67.5h Monday gap only worked because it exceeds the fallback one-resolution span in ShouldWaitForFreshDataOnStale; the 19.5h weekday gap does not.

Fix

When there are no non-internal subscriptions, fall back to evaluating the internal configs with the same all-coarse rule. Behavior is otherwise unchanged: empty config lists still return false, and any fine resolution (internal or not) still returns false. With the fallback, an internal-only daily subscription waits on a stale previous close exactly like a regular daily subscription.

Regression test

New MarketOrderWaitsForFreshDataWithInternalOnlyDailyConfig (Buy/Sell) in Tests/Common/Orders/Fills/FutureFillModelTests.cs: internal-only daily config, previous close 19.5h stale (within one daily bar, past the 1h stale span) must not fill; after a fresh daily bar arrives it fills at the fresh close. Verified the test fails on pre-fix code (both cases fill at the stale price) and passes with the fix.

Verification

In Docker (mcr.microsoft.com/dotnet/sdk:10.0 + Python 3.11 for pythonnet, matching CI's foundation setup):

  • dotnet build ./Tests/QuantConnect.Tests.csproj -c Release: 0 errors
  • dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter FullyQualifiedName~FutureFillModelTests (from Tests/bin/Release): 18/18 passed, including the 2 new cases and all existing fill tests

Fixes #9827

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.

Daily continuous future: market orders on the mapped contract fill at the stale previous close Tuesday to Friday, wait only on Mondays

1 participant