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 events in real-time.

Create and update custom watchlists.

Examples, response types, property details and explanations.

Stream Market Events

  • Available in Sandbox
  • Available in Production
  • Available to Advisors
  • Supported

Stream market updates using HTTP 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.

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.

Note that streaming uses a different endpoint: https://stream.tradier.com
POST

Headers

Header Required Values/Example Default
Accept Optional application/xml, application/json application/xml
Authorization Required Bearer {token}

Parameters

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

Code Example

import json
import requests

headers = {
  'Accept': 'application/json'
}

payload = { 
  'sessionid': 'SESSION_ID',
  'symbols': 'SPY',
  'linebreak': True
}

r = requests.post('https://stream.tradier.com/v1/markets/events', stream=True, params=payload, headers=headers)
for line in r.iter_lines():
  if line:
    print(json.loads(line))
using System;
using System.Net;
using System.IO;
using System.Text;

public class MainClass {
  public static void Main (string[] args) {
    var request = (HttpWebRequest)WebRequest.Create("https://stream.tradier.com/v1/markets/events");

    request.Method = "POST";
    request.Accept = "application/json";
    var requestData = "sessionid=SESSION_ID&symbols=SPY&linebreak=true";
    request.ContentType = "application/x-www-form-urlencoded";
    var data = Encoding.ASCII.GetBytes(requestData);
    request.ContentLength = data.Length;

    using (var stream = request.GetRequestStream())
    {
      stream.Write(data, 0, data.Length);
    }
    
    var response = (HttpWebResponse)request.GetResponse();

    Console.WriteLine (response.StatusCode);
    using (var reader = new StreamReader(response.GetResponseStream())) {
      while (!reader.EndOfStream) {
        var currentLine = reader.ReadLine();
        Console.WriteLine(currentLine);
      }
    }
  }
}

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"
}