Overview

Details about how to obtain access tokens using OAuth 2.0

Fetch positions, balances and other account related details.

Place equity and complex option trades including advanced orders.

Fetch quotes, chains and historical data via REST and streaming APIs.

Stream market data and account events in real-time.

Create and update custom watchlists.

Examples, response types, property details and explanations.

Stream Market Events

  • Available in Paper Trading
  • Available in Production
  • Available to Advisors
  • Supported

Stream market updates using WebSocket streaming. You will receive a different payload depending on the market event that occurred. Details about each event can be found in the response definition. You can continually update the data in your stream by resending this request with different parameters.

Note: In order to stream data, you must first create a streaming session. Upon receiving a sessionid, you will have up to 5 minutes to connect to a streaming endpoint before the session expires.

Once connected and streaming data, to make modifications to your current streaming connection, simply resend your request payload using the existing sessionid. You can change the symbols by resending your payload with an updated list of symbols and we’ll adjust your stream accordingly. Note: if your sessionid has expired, you will need to get a new one and send it with your adjusted payload.

Note that WebSocket streaming uses a different endpoint: wss://ws.tradier.com
While we do not publish the symbol limits for these APIs, we do monitor for abuse to make sure people aren’t doing anything egregious (like asking for an entire exchange worth of symbols). Essentially, ask for what you need. Don’t abuse the APIs and you should be fine. It is not permitted to open more than one session at a time.
WebSocket

Parameters

Parameter Type Param Type Required Values/Example Default
symbols JSON Array Required ["AAPL","VXX190517P00016000"]
An array list of symbols (equity or option)
sessionid JSON String Required 9D1C7018CFEB6F8ECF8CAA58B33
Session Id retrieved from the create session endpoint
filter JSON Array Optional ["trade"] All payloads.
An array list of the types of payloads to retrieve in the stream. trade,quote,summary,timesale,tradex
linebreak JSON Boolean Optional true false
Insert a line break after a completed payload
validOnly JSON Boolean Optional true true
Include only ticks that are considered valid by exchanges.
advancedDetails JSON Boolean Optional true false
Include advanced details in timesale payloads

Code Example

import asyncio
import websockets

async def ws_connect():
    uri = "wss://ws.tradier.com/v1/markets/events"
    async with websockets.connect(uri, ssl=True, compression=None) as websocket:
        payload = '{"symbols": ["SPY"], "sessionid": "SESSION_ID", "linebreak": true}'
        await websocket.send(payload)

        print(f">>> {payload}")

        async for message in websocket:
            print(f"<<< {message}")

asyncio.run(ws_connect())
const WebSocket = require('ws');
const ws = new WebSocket('wss://ws.tradier.com/v1/markets/events');

ws.on('open', function open() {
  console.log('Connected, sending subscription commands...');
  ws.send('{"symbols": ["SPY"], "sessionid": "SESSION_ID", "linebreak": true}');
});
ws.on('message', function incoming(data) {
  console.log(data);
});
ws.on('error', function error(data) {
  console.log(data);
});
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;

import java.net.URI;
import java.net.URISyntaxException;

/**
* This example uses org.java-websocket.Java-WebSocket version 1.4.1
*
* For more details, please access https://github.com/TooTallNate/Java-WebSocket
* */
public class Main {
  public static void main(String[] args) throws URISyntaxException {
    final ClientExample client = new ClientExample(new URI("wss://ws.tradier.com/v1/markets/events"));
    client.connect();
  }
}

class ClientExample extends WebSocketClient {

  public ClientExample(URI serverURI) {
    super(serverURI);
  }

  @Override
  public void onOpen(ServerHandshake handshakedata) {
  System.out.println("opened connection");
  send("{" +
        "\"symbols\": [\"SPY\"], " +
        "\"sessionid\": \"SESSION_ID\", " +
        "\"linebreak\": true" +
      "}");
  }

  @Override
  public void onMessage(String message) {
    System.out.println("Received: " + message);
  }

  @Override
  public void onClose(int code, String reason, boolean remote) {
    System.out.println("Connection closed by " + (remote ? "remote peer" : "us") + " Code: " + code + " Reason: " + reason);
  }

  @Override
  public void onError(Exception e) {
    System.err.println("Exception: " + e.getMessage());
  }
}
require 'faye/websocket'
require 'eventmachine'

EM.run do
  ws = Faye::WebSocket::Client.new('wss://ws.tradier.com/v1/markets/events')

  ws.on :open do |event|
    puts :open
    ws.send('{"symbols": ["SPY"], "sessionid": "SESSION_ID", "linebreak": true}')
  end

  ws.on :message do |event|
    puts event.data
  end

  ws.on :close do |event|
    puts :close, event.code, event.reason
    ws = nil
  end
end

Response

Response Definition

{
  "type": "quote",
  "symbol": "SPY",
  "bid": 281.84,
  "bidsz": 60,
  "bidexch": "M",
  "biddate": "1557757189000",
  "ask": 281.85,
  "asksz": 6,
  "askexch": "Z",
  "askdate": "1557757190000"
}
{
  "type": "trade",
  "symbol": "SPY",
  "exch": "J",
  "price": "281.85",
  "size": "100",
  "cvol": "27978993",
  "date": "1557757190000",
  "last": "281.85"
}
{
  "type": "summary",
  "symbol": "SPY",
  "open": "282.42",
  "high": "283.49",
  "low": "281.07",
  "prevClose": "288.1"
}
{
  "type": "timesale",
  "symbol": "SPY",
  "exch": "Q",
  "bid": "282.08",
  "ask": "282.09",
  "last": "282.09",
  "size": "100",
  "date": "1557758874355",
  "seq": 352795,
  "flag": "",
  "cancel": false,
  "correction": false,
  "session": "normal"
}
{
  "type": "tradex",
  "symbol": "SPY",
  "exch": "J",
  "price": "281.85",
  "size": "100",
  "cvol": "27978993",
  "date": "1557757190000",
  "last": "281.85"
}