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 TypeEquityEquity Options
MarketOrdergreen checkgreen check
LimitOrdergreen checkgreen check
StopMarketOrdergreen checkgreen check
StopLimitOrdergreen checkgreen check

Time In Force

The TradierBrokerageModel supports the following TimeInForce instructions:

  • Day
  • GoodTilCanceled (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:

ErrorDescription
ShortOrderIsGtcYou can't short sell with the GoodTilCanceled time in force
SellShortOrderLastPriceBelow5You can't short sell stocks below $5
IncorrectOrderQuantityThe 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.

security.set_slippage_model(NullSlippageModel.instance);
security.set_slippage_model(NullSlippageModel.instance)

Fees

The TradierBrokerageModel uses the ConstantFeeModel with zero fees.

security.SetFeeModel(new ConstantFeeModel(0.0m));
security.set_fee_model(ConstantFeeModel(0))

Buying Power

The TradierBrokerageModel uses the OptionMarginModel for Option trades and the SecurityMarginModel for Equity trades.

If you have a margin account, the TradierBrokerageModel allows 2x leverage for Equities.

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.

Default Markets

The default market of the TradierBrokerageModel is Market.USA.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: