Supported Models
Tradier
Introduction
This page explains the TradierBrokerageModel, including the asset classes it supports, its default security-level models, and its 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)
For more information about this model, see the class reference and implementation.
For more information about this model, see the class reference and implementation.
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 | ![]() | ![]() |
Order Properties
The TradierBrokerageModel supports custom order properties. The following table describes the members of the TradierOrderProperties object that you can set to customize order execution.
| Property | Data Type | Description | Default Value |
|---|---|---|---|
TimeInForcetime_in_force | TimeInForce | A TimeInForce instruction to apply to the order. The following instructions are supported:
| TimeInForce.GoodTilCanceledTimeInForce.GOOD_TIL_CANCELED |
OutsideRegularTradingHoursoutside_regular_trading_hours | bool | A flag to signal that the order may be triggered and filled outside of regular trading hours. | falseFalse |
public override void Initialize()
{
// Set the default order properties
DefaultOrderProperties = new TradierOrderProperties
{
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 TradierOrderProperties
{
TimeInForce = TimeInForce.Day
});
LimitOrder(_symbol, quantity, limitPrice,
orderProperties: new TradierOrderProperties
{
OutsideRegularTradingHours = true,
TimeInForce = TimeInForce.GoodTilDate(new DateTime(year, month, day))
});
} def initialize(self) -> None:
# Set the default order properties
self.default_order_properties = TradierOrderProperties()
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 = TradierOrderProperties()
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 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 GoodTilCanceledGOOD_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.
Account Currency
The TradierBrokerageModel doesn't set a default currency.
To change the algorithm's currency from USD to a different currency, see Set Account Currency.
