TradeStationBrokerageModel rejects extended-hours limit orders on equity options
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
Direzione di ricerca
Inizia da Common/Brokerages/TradeStationBrokerageModel.cs, in corrispondenza del controllo CanSubmitOrder descritto nell’issue. Leggi le proprietà degli ordini TradeStation e la mappatura della validità temporale per confermare quali tipi di ordine e di titolo sono accettati. Aggiorna il controllo di idoneità e il testo dell’avviso come proposto, continuando a rifiutare le opzioni su indici; il lavoro è concluso quando gli ordini limit su azioni e opzioni su azioni con il flag passano, mentre i tipi non supportati continuano a essere rifiutati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
masterbranch - 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.
- Lingua principale
- C#
- Stelle
- 22k
- Fork
- 5.3k
- Merge medio
- 1g 6h
- PR unite (30g)
- 47
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di QuantConnect/Lean
-
WebullFeeModel charges SPXW options the SPX exchange feeForse già presa @Amadeus-22 l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
QuantConnect/Lean#9922 ·
I maintainer di solito rispondono entro 1 giorno
-
AlpacaBrokerageModel refuses extended-hours limit orders with the GTC time in force, which Alpaca acceptsForse già presa @AlexCatarino l’ha presa 8 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
QuantConnect/Lean#9892 ·
I maintainer di solito rispondono entro 1 giorno
-
GetMarketHours: a late open after the day's last segment keeps the whole day openForse già presa @abhi-byte62 l’ha presa 5 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
QuantConnect/Lean#9889 ·
I maintainer di solito rispondono entro 1 giorno
-
library-request
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
QuantConnect/Lean#9879 ·
I maintainer di solito rispondono entro 1 giorno
-
[Library Upgrade] autogluonApertalibrary-request
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
QuantConnect/Lean#9743 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di QuantConnect/Lean
Issue simili
-
area-TableView bug needs-triage team-Controls
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
microsoft/microsoft-ui-xaml#12351 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
AudioClient and ImageClient file path overloads send the full local path as the multipart file nameForse già presa @sebxt l’ha presa oggi. Apertaarea: audio area: images feature-request
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
openai/openai-dotnet#1453 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
I maintainer di solito rispondono entro 1 giorno
-
needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
elsa-workflows/elsa-foundation#3130 ·
I maintainer di solito rispondono entro 1 giorno
-
遥测历史查询始终返回 HTTP 400,页面静默无结果Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100