Skip to content

Respect outside regular hours in fill models#9483

Open
aiSynergy37 wants to merge 4 commits into
QuantConnect:masterfrom
aiSynergy37:bug-9476-respect-regular-hours
Open

Respect outside regular hours in fill models#9483
aiSynergy37 wants to merge 4 commits into
QuantConnect:masterfrom
aiSynergy37:bug-9476-respect-regular-hours

Conversation

@aiSynergy37

Copy link
Copy Markdown
Contributor

Description

Updates fill eligibility to respect order-level outside regular trading hours settings when the order properties expose that setting. This prevents extended-hours subscriptions from filling orders that explicitly disallow outside regular trading hours.

The shared exchange-open helper now applies the order property override before checking market hours, and short bars no longer use the large-bar boundary fallback when the exchange is closed at the order time.

Related Issue

Fixes #9476

Motivation and Context

A stop market order submitted during pre-market data could fill when the subscription had extended market hours enabled, even if the order property set OutsideRegularTradingHours = false.

Requires Documentation Change

No

How Has This Been Tested?

  • dotnet build Tests\QuantConnect.Tests.csproj --no-restore -v minimal /p:RunAnalyzers=false
  • Added a regression test covering both allowed and disallowed outside-regular-hours stop market fills.

Types of Changes

  • Bug fix
  • Tests

@hyperxiaoerxz-hash

Copy link
Copy Markdown

Nice targeted fix. Since this PR routes several fill paths through the new order-aware exchange-open check, the main thing I would want to lock down is coverage across the paths touched by the diff.

Potential extra regression cases:

  • OutsideRegularTradingHours = false blocks pre-market and post-market fills for each touched order type: market, stop market, trailing stop, stop limit, limit-if-touched, and limit.
  • OutsideRegularTradingHours = true still allows valid extended-hours fills when the subscription has extended-market data, so the new check does not accidentally over-block.
  • Unknown/custom OrderProperties types keep the previous subscription-driven fallback behavior.
  • Each supported brokerage property class is exercised at least once: Alpaca, IB, Tradier, and TradeStation.
  • Boundary timestamps are explicit: one minute before open, market open, market close, and one minute after close.
  • A GTC order active across sessions applies the property at fill-evaluation time, not only at submission time.

One related composition check: this should stay separate from engine-generated fills such as delisting liquidations. User-order session constraints should be enforced here, while automatic engine liquidations should not be accidentally blocked by a default OutsideRegularTradingHours = false setting.

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.

Fill Model Don't Account IOrderPropeties.OutsideRegularTradingHours

3 participants