MarketOnClose fills are not capped by volume: an order larger than the closing volume fills in full at the close
Maintainers usually reply within 1 day
@kavindon2007 is already working on this.
Since Oct 28, 2026.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 43/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- csharp
- Domain
- backend, fintech-quant
Research direction
Start by reading EquityFillModel.MarketOnCloseFill and the HourlyDelistingLiquidationAtMarketCloseRegressionAlgorithm example from #9932. Compare the fill quantity with the available closing tick or bar volume, including the case where the last bar is stale; inspect BacktestingBrokerage.HandleDelistingNotification for the midnight fallback. Done means the issue's volume behavior is addressed or documented consistently, while preserving any intended opt-in behavior.
Written by the indexing model from the issue text.
Description
Expected Behavior
A backtest MarketOnClose order for more shares than traded around the close should not be assumed to fill in full at the closing price, or there should be an opt-in way to cap it. For example, a fill model could limit the fill to a share of the closing auction or last bar volume, and leave the rest unfilled or partially filled.
Actual Behavior
EquityFillModel.MarketOnCloseFill fills the whole order quantity once the local time reaches the next market close. It uses the official close tick, or the last trade bar close, and applies the slippage model only to the price. Nothing caps the quantity by volume, and the last known bar can be stale.
Example from the local data: the GDVD hourly regression (HourlyDelistingLiquidationAtMarketCloseRegressionAlgorithm, from #9932) holds 1555 shares through the 2021-01-20 delisting. The last bar before the close is 2021-01-19 15:00 with a volume of 100, and there are no bars on 2021-01-20. The MarketOnClose liquidation still fills all 1555 shares at 2021-01-20 16:00, at 31.905.
This applies to every MarketOnClose order, not just delisting liquidations. On master the delisting fallback (BacktestingBrokerage.HandleDelistingNotification) also fills the full holding at midnight.
Potential Solution
- An opt-in volume limit for
MarketOnClose(andMarketOnOpen) fills inEquityFillModel, based on the volume of the closing bar or tick. It could be a parameter or a separate fill model, so existing results don't change. - Or document that close and open auction fills are not volume constrained, and that price impact is modeled only through the slippage model, e.g.
VolumeShareSlippageModel.
Checklist
- I have completely filled out this template
- I have confirmed that this issue exists on the current
masterbranch - I have confirmed that this is not a duplicate issue by searching issues
- Dominant language
- C#
- Stars
- 22.6k
- Forks
- 5.4k
- Avg merge
- 11h 39m
- Merged PRs (30d)
- 104
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from QuantConnect/Lean
-
priority:p2
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
QuantConnect/Lean#10216 ·
Maintainers usually reply within 1 day
-
priority:p2
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
QuantConnect/Lean#10206 ·
Maintainers usually reply within 1 day
-
priority:p2
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
QuantConnect/Lean#10199 ·
Maintainers usually reply within 1 day
-
priority:p2
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
QuantConnect/Lean#10198 ·
Maintainers usually reply within 1 day
-
priority:p2
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
QuantConnect/Lean#10197 ·
Maintainers usually reply within 1 day
All issues in QuantConnect/Lean
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
dotnet-outdated/dotnet-outdated#871 ·
Maintainers usually reply within 1 day
-
triage/untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
unoplatform/uno#26676 ·
Maintainers usually reply within 1 day
-
.NET bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
jhaizhou-ops/S2Arm#2177 · 3 comments ·
Maintainers usually reply within 1 day
-
area-CodeGen-coreclr untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
dotnet/runtime#138181 · 1 comment ·
Maintainers usually reply within 1 day