Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

TradeStationBrokerageModel rejects extended-hours limit orders on equity options

Open Beginner friendly
#9,920 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@AlexCatarino is already working on this.

Since Oct 20, 2026.

  • #9928 by @AlexCatarino — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp
Domain
api, backend

Research direction

Start with Common/Brokerages/TradeStationBrokerageModel.cs around the CanSubmitOrder check described in the issue. Read the TradeStation order properties and time-in-force mapping to confirm which order types and security types are accepted. Update the eligibility check and warning text as proposed, keeping index options rejected; done means equity and equity-option limit orders with the flag pass while unsupported types remain rejected.

Written by the indexing model from the issue text.

Description

bug

Expected Behavior

With the TradeStation brokerage model, a limit order on an equity option carrying TradeStationOrderProperties.OutsideRegularTradingHours = true should pass CanSubmitOrder and reach the brokerage with the extended-hours duration (DYP / GCP / GDP).

TradeStation opened extended-hours options trading on 2026-10-19 (Cboe sessions 07:30-09:25 ET and 16:00-16:15 ET, limit orders only, Day+ / GTC+ / GTD+ durations, options on a set of single stocks and ETFs): https://www.tradestation.com/insights/extended-hours-options-trading/

Actual Behavior

TradeStationBrokerageModel.CanSubmitOrder rejects every order with the flag set unless it is a limit order on an equity, so an extended-hours option limit order is marked Invalid before it reaches the brokerage, in backtesting and in live trading alike:

BrokerageModel declared unable to submit order: [1] Warning - Code: NotSupportedOutsideRegularMarketHours - To place an order outside regular trading hours, please use a limit order and ensure the security is an equity.

Common/Brokerages/TradeStationBrokerageModel.cs (master, lines 132-138):

var supportsOutsideTradingHours = (order.Properties as TradeStationOrderProperties)?.OutsideRegularTradingHours ?? false;
if (supportsOutsideTradingHours && (order.Type != OrderType.Limit || order.SecurityType != SecurityType.Equity))
{
    message = new BrokerageMessageEvent(BrokerageMessageType.Warning, "NotSupportedOutsideRegularMarketHours",
        "To place an order outside regular trading hours, please use a limit order and ensure the security is an equity.");
    return false;
}

The brokerage plugin itself does not restrict by asset class: TradeStationExtensions.GetBrokerageTimeInForce maps Day / GTC / GTD to DayPlus / GoodTillCanceledPlus / GoodThroughDatePlus whenever the flag is set, for any security type, and TradeStationApiClient.CreatePlaceOrderRequest passes that duration through. Only the engine-side model stands in the way.

Reproduce

QC Cloud, LEAN 2.5.0.0.18194, project 38117137, backtest 1be63f12c2f791724afe25fd9ea34d4a. One option limit order and one equity limit order, both with the flag set, under the TradeStation model:

from AlgorithmImports import *


class TradeStationExtendedHoursOptionOrderRepro(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 1, 2)
        self.set_end_date(2024, 1, 3)
        self.set_cash(100000)
        self.set_brokerage_model(BrokerageName.TRADE_STATION, AccountType.MARGIN)
        self._equity = self.add_equity("SPY", Resolution.MINUTE).symbol
        option = self.add_option("SPY", Resolution.MINUTE)
        option.set_filter(-2, 2, 0, 30)
        self._option = option.symbol
        self._done = False

    def on_data(self, slice: Slice) -> None:
        if self._done:
            return
        chain = slice.option_chains.get(self._option)
        if not chain:
            return
        contract = sorted(chain, key=lambda c: abs(c.strike - chain.underlying.price))[0]

        props = TradeStationOrderProperties()
        props.outside_regular_trading_hours = True
        props.time_in_force = TimeInForce.DAY

        limit = contract.bid_price if contract.bid_price > 0 else 0.5
        option_ticket = self.limit_order(contract.symbol, 1, limit, order_properties=props)
        self.log(f"OPTION limit order {option_ticket.order_id} on {contract.symbol.value}: status={option_ticket.status}")

        equity_price = self.securities[self._equity].price
        equity_ticket = self.limit_order(self._equity, 1, round(equity_price * 0.99, 2), order_properties=props)
        self.log(f"EQUITY limit order {equity_ticket.order_id} on SPY: status={equity_ticket.status}")
        self._done = True

    def on_order_event(self, order_event: OrderEvent) -> None:
        self.log(f"ORDER EVENT: {order_event}")

Output:

2024-01-02 09:31:00 BrokerageModel declared unable to submit order: [1] Warning - Code: NotSupportedOutsideRegularMarketHours - To place an order outside regular trading hours, please use a limit order and ensure the security is an equity.
2024-01-02 09:31:00 OPTION limit order 1 on SPY   240102C00474000: status=INVALID
2024-01-02 09:31:00 EQUITY limit order 2 on SPY: status=SUBMITTED

Proposed change

Accept SecurityType.Option alongside SecurityType.Equity in that check (the order type must stay Limit, which matches TradeStation's rule), and update the message accordingly. TradeStation then applies its own eligibility rules (which option classes, which session) and rejects what it does not accept, as it does for equities today.

Open question: whether SecurityType.IndexOption should be included. TradeStation's announcement covers options on select stocks and ETFs; Cboe's index options (SPX, VIX) trade in their own global trading hours session, and we have not confirmed whether TradeStation routes DYP / GCP / GDP index option orders. The fix here leaves index options rejected.

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
  • I have provided detailed steps to reproduce the issue

Intercom conversation 215476463234198.

Dominant language
C#
Stars
22.1k
Forks
5.3k
Avg merge
1d 8h
Merged PRs (30d)
32

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.