fix fills wait for fresh data on internal-only coarse subscriptions - #9836
Open
Tyagiquamar wants to merge 1 commit into
Open
Tyagiquamar wants to merge 1 commit into
Tyagiquamar wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 withSetFilter(0, 90)it always waits, which points at the wait-condition rather than data.Root cause
In
Common/Orders/Fills/FillModel.cs,ShouldWaitForFreshDataonly lets non-internal subscriptions decide whether all subscribed resolutions are coarse, and returnshasNonInternal. The mapped contract of a continuous future is internal-only by construction (ContinuousContractUniverse.GetSubscriptionRequestsmarks 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 inShouldWaitForFreshDataOnStale; 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) inTests/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 errorsdotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter FullyQualifiedName~FutureFillModelTests(fromTests/bin/Release): 18/18 passed, including the 2 new cases and all existing fill testsFixes #9827