WebSocket Market Data Streaming
Stream market updates using WebSocket streaming. You will receive a different payload depending on the market event that occurred — details about each event’s fields are in Streaming Market Data. You can continually update the data in your stream by resending this request payload using your existing sessionid.
Note: in order to stream data, you must first create a streaming session via Create Market Session. Upon receiving a sessionid, you have up to 5 minutes to connect to a streaming endpoint before the session expires.
Once connected and streaming data, to change the symbols you’re subscribed to, simply resend your request payload with an updated symbols list using the same sessionid — no reconnect required. If your sessionid has expired, you’ll need a new one. filter cannot be changed this way — it’s fixed for the lifetime of a given WebSocket connection (see Streaming for more on this distinction).
While we do not publish exact symbol limits, we monitor for abuse (e.g. requesting an entire exchange’s worth of symbols). Ask for what you need and you should be fine. It is not permitted to open more than one session at a time.
Note that WebSocket streaming uses a different host: wss://ws.tradier.com
wss://ws.tradier.com/v1/markets/eventsRequest Payload
symbols | array | List of symbols (equity or option) to subscribe to | Yes | ["AAPL", "TSLA250815C00150000"] | N/A |
sessionid | string | Session ID retrieved from the create market session endpoint | Yes | "9D1C7018CFEB6F8ECF8CAA58B33" | N/A |
filter | array | Types of payloads to include in the stream | No | ["trade","quote","summary","timesale","tradex"] | All payload types |
linebreak | boolean | Insert a line break after a completed payload | No | true | false |
validOnly | boolean | Include only ticks considered valid by the exchange | No | true | true |
advancedDetails | boolean | Include advanced/extended details in timesale payloads | No | true | false |
linebreak, validOnly, and advancedDetails are documented as JSON booleans, though examples elsewhere are sometimes shown as quoted strings ("true"/"false") — send actual boolean true/false values in your JSON payload.
In the event of validation issues with your request, expect an error payload:
{"error":"1234 is not a valid symbol"}
Code Example (Python)
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"], "filter": ["quote"], "sessionid": "SESSION_ID", "linebreak": true}'
await websocket.send(payload)
async for message in websocket:
print(f"<<< {message}")
asyncio.run(ws_connect())
Response Example
{"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"}
On this page
- WebSocket Market Data Streaming