Supported Models
TradeStation
Introduction
This page explains the TradeStationBrokerageModel
, including the asset classes it supports, its default security-level models, and its default markets.
SetBrokerageModel(BrokerageName.TradeStation, AccountType.Cash); SetBrokerageModel(BrokerageName.TradeStation, AccountType.Margin);
self.set_brokerage_model(BrokerageName.TRADE_STATION, AccountType.CASH) self.set_brokerage_model(BrokerageName.TRADE_STATION, AccountType.MARGIN)
To view the implementation of this model, see the LEAN GitHub repository.
Orders
The TradeStationBrokerageModel
supports several order types, order properties, and order updates.
Order Types
The following table describes the available order types for each asset class that the TradeStationBrokerageModel
supports:
Order Type | Equity | Equity Options | Index Options | Futures |
---|---|---|---|---|
Market | ![]() | ![]() | ![]() | ![]() |
Limit | ![]() | ![]() | ![]() | ![]() |
Stop market | ![]() | ![]() | ![]() | ![]() |
Stop limit | ![]() | ![]() | ![]() | ![]() |
Market on Open | ![]() | |||
Market on Close | ![]() | |||
Combo market | ![]() | ![]() | ![]() | ![]() |
Combo limit | ![]() | ![]() | ![]() | ![]() |
Order Properties
The TradeStationBrokerageModel
supports custom order properties. The following table describes the members of the TradeStationOrderProperties
object that you can set to customize order execution.
Property | Data Type | Description | Default Value |
---|---|---|---|
TimeInForce time_in_force | TimeInForce | A TimeInForce instruction to apply to the order. The following instructions are supported:
| TimeInForce.GoodTilCanceled TimeInForce.GOOD_TIL_CANCELED |
OutsideRegularTradingHours outside_regular_trading_hours | bool | A flag to signal that the order may be triggered and filled outside of regular trading hours. |
public override void Initialize() { // Set the default order properties DefaultOrderProperties = new TradeStationOrderProperties { OutsideRegularTradingHours = false, TimeInForce = TimeInForce.GoodTilCanceled }; } public override void OnData(Slice slice) { // Use default order order properties LimitOrder(_symbol, quantity, limitPrice); // Override the default order properties LimitOrder(_symbol, quantity, limitPrice, orderProperties: new TradeStationOrderProperties { TimeInForce = TimeInForce.Day }); LimitOrder(_symbol, quantity, limitPrice, orderProperties: new TradeStationOrderProperties { OutsideRegularTradingHours = true, TimeInForce = TimeInForce.GoodTilDate(new DateTime(year, month, day)) }); }
def initialize(self) -> None: # Set the default order properties self.default_order_properties = TradeStationOrderProperties() self.default_order_properties.outside_regular_trading_hours = False self.default_order_properties.time_in_force = TimeInForce.GOOD_TIL_CANCELED def on_data(self, slice: Slice) -> None: # Use default order order properties self.limit_order(self._symbol, quantity, limit_price) # Override the default order properties order_properties = TradeStationOrderProperties() order_properties.time_in_force = TimeInForce.DAY self.limit_order(self._symbol, quantity, limit_price, order_properties=order_properties) order_properties.time_in_force = TimeInForce.good_til_date(datetime(year, month, day)) order_properties.outside_regular_trading_hours = True self.limit_order(self._symbol, quantity, limit_price, order_properties=order_properties)
Updates
The TradeStationBrokerageModel
supports order updates.
Handling Splits
If you're using raw data normalization and you have active orders with a limit, stop, or trigger price in the market for a US Equity when a stock split occurs, the following properties of your orders automatically adjust to reflect the stock split:
- Quantity
- Limit price
- Stop price
- Trigger price
Fills
The following table shows the fill model that the TradeStationBrokerageModel
uses for each SecurityType
:
SecurityType | Fill Model |
---|---|
Equity | EquityFillModel |
Option | ImmediateFillModel |
Future | FutureFillModel |
Slippage
The TradeStationBrokerageModel
uses the NullSlippageModel.
Fees
The TradeStationBrokersBrokerageModel
uses the TradeStationFeeModel with the default argument values. We model current TradeStation fees on all assets.
Buying Power
The TradeStationBrokerageModel
sets the buying power model based on the asset class of the security. The following table shows the default buying power model of each asset class:
Asset Class | Model |
---|---|
Equities | SecurityMarginModel |
Equity Options | OptionMarginModel |
Futures | FutureMarginModel |
If you have a margin account, the TradeStationBrokerageModel
allows 2x leverage for Equities and and 1x leverage for Equity Options and Futures.
Settlement
The following table shows which settlement model the TradeStationBrokerageModel
uses based on the security type and your account type:
Security Type | Account Type | Settlement Model |
---|---|---|
Equity | Cash | DelayedSettlementModel with the default settlement rules |
Option | Cash | DelayedSettlementModel with the default settlement rules |
Future | Any | FutureSettlementModel |
For all other cases, the TradeStationBrokerageModel
uses the ImmediateSettlementModel.
// For US Equities with a cash account: security.SetSettlementModel(new DelayedSettlementModel(Equity.DefaultSettlementDays, Equity.DefaultSettlementTime)); // For Equity Options with a cash account: security.SetSettlementModel(new DelayedSettlementModel(Option.DefaultSettlementDays, Option.DefaultSettlementTime)); // For Futures security.SetSettlementModel(new FutureSettlementModel()); // For remaining cases: security.SetSettlementModel(new ImmediateSettlementModel());
# For US Equities with a cash account: security.set_settlement_model(DelayedSettlementModel(Equity.DEFAULT_SETTLEMENT_DAYS, Equity.DEFAULT_SETTLEMENT_TIME)) # For Equity Options with a cash account: security.set_settlement_model(DelayedSettlementModel(Option.DEFAULT_SETTLEMENT_DAYS, Option.DEFAULT_SETTLEMENT_TIME)) # For Futures security.set_settlement_model(FutureSettlementModel()) # For remaining cases: security.set_settlement_model(ImmediateSettlementModel())
Margin Interest Rate
The TradeStationBrokerageModel
uses the NullMarginInterestRateModel.