MarketOnClose fills are not capped by volume: an order larger than the closing volume fills in full at the close

Open
#9,972 6 comments 0 reactions 0 assignees View on GitHub

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

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 (and MarketOnOpen) fills in EquityFillModel, 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 master branch
  • 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

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from QuantConnect/Lean

All issues in QuantConnect/Lean

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.