QuantConnect / QuantConnect/Lean

Fill Model Don't Account IOrderPropeties.OutsideRegularTradingHours

Open
#9,476 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
21.7k
Forks
5.3k
Avg merge
2d 22h
Merged PRs (30d)
34

Description

Expected Behavior

If the data susbcription includes extended market hours, but the order property OutsideRegularTradingHours is false, the orders can't be filled.

Actual Behavior

OutsideRegularTradingHours is not accounted for.

namespace QuantConnect.Algorithm.CSharp
{
    public class GeekyRedDogfish : QCAlgorithm
    {

        public override void Initialize()
        {
            SetStartDate(2026, 5, 5);
            SetEndDate(2026, 5, 5);
            SetCash(100000);

            AddEquity("SPY", Resolution.Minute, extendedMarketHours: true);
        }

        public override void OnData(Slice data)
        {
            foreach (var kvp in data.Bars)
            {
                var symbol = kvp.Key;
                if (Time.TimeOfDay == new TimeSpan(9, 29, 0))
                {
                    OrderProperties prop = new TradeStationOrderProperties
                    {
                        TimeInForce = TimeInForce.Day,
                        OutsideRegularTradingHours = false,
                    };
                    var stopOrder = StopMarketOrder(
                            symbol,
                            10,
                            1.0m,
                            tag: "my tag",
                            orderProperties: prop
                        );
                }
            }
        }
    }
}
Potential Solution

N/A

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

Contributor guide

Open the contributing guide

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.

Research direction

Start with the provided GeekyRedDogfish C# reproduction and trace the order fill path for an extended-hours SPY subscription. Check how OutsideRegularTradingHours is handled when it is false; done means the stop order is not filled outside regular trading hours while extended-hours data remains enabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.