Brokerages

Tradier

Introduction

QuantConnect enables you to run your algorithms in live mode with real-time market data. We have successfully hosted more than 200,000 live algorithms and have had more than $15B in volume traded on our servers since 2015. Brokerages supply a connection to the exchanges so that you can automate orders using LEAN. You can use multiple data feeds in live trading algorithms.

Tradier was founded by Dan Raju, Peter Laptewicz, Jason Barry, Jeyashree Chidambaram, and Steve Agalloco in 2012 with the goal to "deliver a choice of low-cost, high-value brokerage services to traders". Tradier provides access to trading Equities and Options for clients in over 250 countries and territories with no minimum deposit for cash accounts. Tradier also delivers custody, clearing, execution, and billing on behalf of registered advisors.

Account Types

Tradier supports cash and margin accounts.

SetBrokerageModel(BrokerageName.TradierBrokerage, AccountType.Cash);
SetBrokerageModel(BrokerageName.TradierBrokerage, AccountType.Margin);
self.SetBrokerageModel(BrokerageName.TradierBrokerage, AccountType.Cash)
self.SetBrokerageModel(BrokerageName.TradierBrokerage, AccountType.Margin)

Create an Account

Follow the account creation wizard on the Tradier website to create a Tradier account.

You will need your account ID and access token to deploy live algorithms. After you have an account, get your account ID and token from the Settings > API Access page on the Tradier website. Your account ID is the alpha-numeric code in a drop-down field on the page.

Paper Trading

Tradier supports paper trading, but with the following caveats:

  • Account activity is unavailable since this information is populated from Tradier's clearing firm.
  • Streaming Tradier market data is unavailable due to exchange restrictions related to delayed data.

To get your paper trading account number and access token, open the API Access page on the Tradier website and then scroll down to the Sandbox Account Access (Paper Trading) section.

If you trade Equities, you can use the QuantConnect data feed to get real-time data. If you trade Options, you must use delayed data from the Tradier data feed. If you trade Equities and Options, use the Tradier data feed. We don't currently have a hybrid QuantConnect-Tradier data feed. If you trade with the demo environment, Tradier doesn't offer streaming market data due to exchange restrictions related to delayed data, so you must use our data feed.

Asset Classes

Tradier supports trading Equities and Options.

AddEquity("SPY", Resolution.Minute, Market.USA);

AddOption("SPY", Resolution.Minute, Market.USA);
self.AddEquity("SPY", Resolution.Minute, Market.USA)
        
self.AddOption("SPY", Resolution.Minute, Market.USA)

If you call the SetBrokerageModel method with the correct BrokerageName, then you don't need to pass a Market argument to the method calls above because the brokerage model automatically selects the correct market.

Assets Available

Refer to the dataset listing of the asset class you are trading to see the assets available. The following table shows the dataset listing of each asset class supported by Tradier:

Asset ClassDataset Listing
EquitiesUS Equities
OptionsUS Equity Options

Data Feeds

You might need to purchase a Tradier data feed subscription. For more information about live data feeds, see Data Feeds.

ETFs

You may not be able to trade all assets with Tradier. For example, if you live in the EU, you can’t trade US ETFs. Check with your local regulators to know which assets you are allowed to trade. You may need to adjust settings in your brokerage account to live trade some assets.

Orders

We model the Tradier API by supporting several order types and the TimeInForce order property. Tradier partially supports order updates, but does not support trading during extended market hours. When you deploy live algorithms, you can place manual orders through the IDE.

Order Types

Tradier supports the following order types:

  • MarketOrder
  • LimitOrder
  • StopMarketOrder
  • StopLimitOrder
  • LimitIfTouchedOrder
  • ExerciseOption
MarketOrder(_symbol, quantity);
LimitOrder(_symbol, quantity, limitPrice);
StopMarketOrder(_symbol, quantity, stopPrice);
StopLimitOrder(_symbol, quantity, stopPrice, limitPrice);
LimitIfTouchedOrder(_symbol, quantity, triggerPrice, limitPrice);
ExerciseOption(_optionSymbol, quantity);
self.MarketOrder(self.symbol, quantity)
self.LimitOrder(self.symbol, quantity, limit_price)
self.StopMarketOrder(self.symbol, quantity, stop_price)
self.StopLimitOrder(self.symbol, quantity, stop_price, limit_price)
self.LimitIfTouchedOrder(self.symbol, quantity, trigger_price, limit_price)
self.ExerciseOption(self.option_symbol, quantity)

Time In Force

We model the TimeInForce order property from the Tradier API. Tradier supports the following TimeInForce instructions:

  • Day
  • GoodTilCanceled
  • GoodTilDate
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 
               });
    LimitOrder(_symbol, quantity, limitPrice, 
               orderProperties: new OrderProperties
               { 
                   TimeInForce = TimeInForce.GoodTilDate(new DateTime(year, month, day)) 
               });
}
def Initialize(self) -> None:
    # Set the default order properties
    self.DefaultOrderProperties.TimeInForce = TimeInForce.GoodTilCanceled

def OnData(self, slice: Slice) -> None:
    # Use default order order properties
    self.LimitOrder(self.symbol, quantity, limit_price)
    
    # Override the default order properties
    order_properties = OrderProperties()
    order_properties.TimeInForce = TimeInForce.Day
    self.LimitOrder(self.symbol, quantity, limit_price, orderProperties=order_properties)

    order_properties.TimeInForce = TimeInForce.GoodTilDate(datetime(year, month, day))
    self.LimitOrder(self.symbol, quantity, limit_price, orderProperties=order_properties)

Updates

We model the Tradier API by supporting some order updates. You can define the following members of an UpdateOrderFields object to update active orders:

  • LimitPrice
  • StopPrice
  • TriggerPrice
  • Tag
var ticket = StopLimitOrder(_symbol, quantity, stopPrice, limitPrice, tag);
var orderFields = new UpdateOrderFields { 
LimitPrice = newLimitPrice,
StopPrice = newStopPrice,
Tag = newTag
}; ticket.Update(orderFields);
ticket = self.StopLimitOrder(self.symbol, quantity, stop_price, limit_price, tag)
update_fields = UpdateOrderFields()
update_fields.LimitPrice = new_limit_price
update_fields.StopPrice = new_stop_price update_fields.Tag = new_tag ticket.Update(update_fields)

If you need to update the quantity of an order, cancel the order and then submit a new order with the desired quantity.

var ticket = LimitOrder(_symbol, quantity, limitPrice);
ticket.Cancel();
ticket = LimitOrder(_symbol, newQuantity, newLimitPrice);
ticket = self.LimitOrder(self.symbol, quantity, limit_price)
ticket.Cancel()
ticket = self.LimitOrder(self.symbol, new_quantity, new_limit_price)

Extended Market Hours

Tradier does not 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

Tradier automatically cancels the open orders that your algorithm has for securities that perform a reverse split.

Fees

We model the order fees of Tradier. The following table shows the fees of each asset class:

Asset Class
Fee
Equities$0
Options$0.35/contract

There is a $9 fee to exercise Option contracts.

To check the latest fees, see the Pricing page on the Tradier website.

Margin

We model buying power and margin calls to ensure your algorithm stays within the margin requirements.

Buying Power

In the US, Tradier allows up to 2x leverage on Equity trades for margin accounts. In other countries, Tradier may offer different amounts of leverage. To figure out how much leverage you can access, check with your local legislation or contact a Tradier representative. We model the US version of Tradier leverage by default.

Margin Calls

Regulation T margin rules apply. When the amount of margin remaining in your portfolio drops below 5% of the total portfolio value, you receive a warning. When the amount of margin remaining in your portfolio drops to zero or goes negative, the portfolio sorts the generated margin call orders by their unrealized profit and executes each order synchronously until your portfolio is within the margin requirements.

Pattern Day Trading

If all of the following statements are true, you are classified as a pattern day trader:

  • You reside in the United States.
  • You trade in a margin account.
  • You execute 4+ intraday US Equity trades within 5 business days.
  • Your intraday US Equity trades represent more than 6% of your total trades.

Pattern day traders must maintain a minimum equity of $25,000 in their margin account to continue trading. For more information about pattern day trading, see Am I a Pattern Day Trader? on the FINRA website.

The PatternDayTradingMarginModel doesn't enforce minimum equity rules and doesn't limit your trades, but it adjusts your available leverage based on the market state. During regular market hours, you can use up to 4x leverage. During extended market hours, you can use up to 2x leverage.

security.MarginModel = new PatternDayTradingMarginModel();
security.MarginModel = PatternDayTradingMarginModel()

Slippage

Orders through Tradier do not experience slippage in backtests. In live trading, your orders may experience slippage.

Fills

We fill market orders immediately and completely in backtests. In live trading, if the quantity of your market orders exceeds the quantity available at the top of the order book, your orders are filled according to what is available in the order book.

Settlements

If you trade with a margin account, trades settle immediately. If you trade with a cash account, Equity trades settle 3 days after the transaction date (T+3) and Option trades settle on the business day following the transaction (T+1).

security.SettlementModel = new ImmediateSettlementModel();
security.SettlementModel = ImmediateSettlementModel()

Security and Stability

Note the following security and stability aspects of our Tradier integration.

Account Credentials

When you deploy live algorithms with Tradier, we don't save your brokerage account credentials.

API Outages

We call the Tradier API to place live trades. Sometimes the API may be down. Check the Tradier status page to see if the API is currently working.

Deposits and Withdraws

You can deposit and withdraw cash from your brokerage account while you run an algorithm that's connected to the account. We sync the algorithm's cash holdings with the cash holdings in your brokerage account every day at 7:45 AM Eastern Time (ET).

Demo Algorithm

The following algorithm demonstrates the functionality of the Tradier brokerage:

Deploy Live Algorithms

You must have an available live trading node for each live trading algorithm you deploy.

Follow these steps to deploy a live algorithm:

  1. Open the project that you want to deploy.
  2. Click the Deploy Live icon.
  3. On the Deploy Live page, click the Brokerage field and then click Tradier from the drop-down menu.
  4. Enter your Tradier account ID and token.
  5. To get your account ID and token, see Create an Account. Your account details are not saved on QuantConnect.

  6. Click the Environment field and then click one of the environments from the drop-down menu.
  7. The following table shows the supported environments:

    EnvironmentDescription
    RealTrade with real money
    DemoTrade with paper money
  8. Click the Data Provider field and then click one of the data feeds from the drop-down menu.
  9. The following table describes the available data feeds:

    Data FeedDescription
    QuantConnectUse data collected across all of the exchanges. For more details about this data feed, see Data Feeds.
    TradierUse data sourced directly from Tradier. This data feed isn't available for the demo environment. For more details about this data feed, see the Tradier data feed guide.
  10. Click the Node field and then click the live trading node that you want to use from the drop-down menu.
  11. (Optional) Set up notifications.
  12. Configure the Automatically restart algorithm setting.
  13. By enabling automatic restarts, the algorithm will use best efforts to restart the algorithm if it fails due to a runtime error. This can help improve the algorithm's resilience to temporary outages such as a brokerage API disconnection.

  14. Click Deploy.

The deployment process can take up to 5 minutes. When the algorithm deploys, the live results page displays. If you know your brokerage positions before you deployed, you can verify they have been loaded properly by checking your equity value in the runtime statistics, your cashbook holdings, and your position holdings.

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: