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.
Header | Required | Values/Example | Default |
---|---|---|---|
Accept | Optional | application/xml, application/json | application/xml |
Authorization | Required | Bearer {token} |
Parameter | Type | Param Type | Required | Values/Example | Default |
---|---|---|---|---|---|
symbols | Query | String | Required | AAPL,VXX190517P00016000 | |
Comma-delimited list of symbols (equity or option) | |||||
sessionid | Query | String | Required | 9D1C7018CFEB6F8ECF8CAA58B33 | |
Session Id retrieved from the create session endpoint | |||||
filter | Query | String | Optional | trade | All payloads. |
Comma-delimited list of types of payloads to retrieve in the stream. trade,quote,summary,timesale,tradex
|
|||||
linebreak | Query | String | Optional | true | false |
Insert a line break after a completed payload | |||||
validOnly | Query | String | Optional | true | true |
Include only ticks that are considered valid by exchanges. | |||||
advancedDetails | Query | String | Optional | true | false |
Include advanced details in timesale payloads |
import json
import requests
headers = {
'Accept': 'application/json'
}
payload = {
'sessionid': 'SESSION_ID',
'symbols': 'SPY',
'linebreak': True
}
r = requests.get('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?sessionid=SESSION_ID&symbols=SPY&linebreak=true");
request.Method = "GET";
request.Accept = "application/json";
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);
}
}
}
}
{
"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"
}