Supported Models
Tradier
Introduction
This page explains the TradierBrokerageModel
, including the asset classes it supports, its default security-level models, and it's default markets.
SetBrokerageModel(BrokerageName.TradierBrokerage, AccountType.Cash); SetBrokerageModel(BrokerageName.TradierBrokerage, AccountType.Margin);
self.set_brokerage_model(BrokerageName.TRADIER_BROKERAGE, AccountType.CASH) self.set_brokerage_model(BrokerageName.TRADIER_BROKERAGE, AccountType.MARGIN)
To view the implementation of this model, see the LEAN GitHub repository.
Asset Classes
The TradierBrokerageModel
supports trading US Equities and Equity Options.
Orders
The TradierBrokerageModel
supports several order types, order properties, and most order updates.
Order Types
The following table describes the available order types for each asset class that the TradierBrokerageModel
supports:
Order Type | Equity | Equity Options |
---|---|---|
Market | ||
Limit | ||
Stop market | ||
Stop limit |
Time In Force
The TradierBrokerageModel
supports the following TimeInForce instructions:
Day
DAY
GoodTilCanceled
GOOD_TIL_CANCELED
(not available for short selling)
public override void Initialize() { // Set the default order properties DefaultOrderProperties.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 OrderProperties { TimeInForce = TimeInForce.Day }); }
def initialize(self) -> None: # Set the default order properties 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 = OrderProperties() order_properties.time_in_force = TimeInForce.DAY self.limit_order(self._symbol, quantity, limit_price, order_properties=order_properties)
Updates
The TradierBrokerageModel
supports most order updates. To update the quantity of an order, cancel the order and then submit a new order with the desired quantity. For more information about this workaround, see the Workaround for Brokerages That Don’t Support Updates.
Extended Market Hours
The TradierBrokerageModel
doesn't support extended market hours trading. If you place an order outside of regular trading hours, the order will be processed at market open.
Automatic Cancellations
If you have open orders for a security when it performs a reverse split, the TradierBrokerageModel
automatically cancels your orders.
Errors
To view the order-related error codes from Tradier, see Error Responses in their documentation.
The TradierBrokerageModel
validates your orders for the following errors before sending them to Tradier:
Error | Description |
---|---|
ShortOrderIsGtc | You can't short sell with the GoodTilCanceled GOOD_TIL_CANCELED time in force |
SellShortOrderLastPriceBelow5 | You can't short sell stocks below $5 |
IncorrectOrderQuantity | The order quantity must be between 1 and 10,000,000 shares |
Fills
The TradierBrokerageModel
uses the EquityFillModel for Equity trades and the ImmediateFillModel for Option trades.
Slippage
The TradierBrokerageModel
uses the NullSlippageModel.
Fees
The TradierBrokerageModel
uses the ConstantFeeModel with zero fees.
security.SetFeeModel(new ConstantFeeModel(0.0m));
security.set_fee_model(ConstantFeeModel(0))
Settlement
The TradierBrokerageModel
uses the ImmediateSettlementModel for margin accounts and the DelayedSettlementModel with the default settlement rules for cash accounts.
// 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 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 remaining cases: security.set_settlement_model(ImmediateSettlementModel())
Margin Interest Rate
The TradierBrokerageModel
uses the NullMarginInterestRateModel.