Fix stop-limit fills after trigger bar - #9778
Open
matvt-cell wants to merge 1 commit into
Open
Conversation
matvt-cell
force-pushed
the
bug-9773-stop-limit-fill
branch
from
September 7, 2026 18:15
cc41ace to
a79601f
Compare
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.
Description
Updates stop-limit fill handling so that bars after the stop has already triggered use resting limit-order semantics.
The trigger bar retains the existing conservative close-based check because OHLC data does not reveal whether the bar's high/low occurred before or after the stop trigger. On subsequent bars, the entire bar is post-trigger, so:
The change is applied to both
EquityFillModel.StopLimitFilland the baseFillModel.StopLimitFill.Related Issue
Fixes #9773
Motivation and Context
After a stop-limit order triggered, LEAN continued to apply the close-based limit test on every subsequent bar.
This could leave an already-triggered stop-limit order unfilled even when a later bar traded through its limit price, as long as that bar did not also close through the limit.
The close-based rule is appropriate on the trigger bar because the ordering of OHLC values is unknown. It is unnecessarily conservative on later bars, where the entire price range necessarily occurred after the stop had already triggered.
This change distinguishes those two cases and applies the existing resting limit-order behavior to subsequent bars.
Requires Documentation Change
No.
How Has This Been Tested?
Added regression coverage for both
EquityFillModeland the baseFillModel, including:Local test results:
EquityFillModelTestsandImmediateFillModelTests: 236/236 passedTypes of changes
Checklist:
bug-<issue#>-<description>orfeature-<issue#>-<description>