Quickstart
Stream trades from the market-data socket
This walks the market-data WebSocket end to end: connect, authenticate, subscribe, read frames. You need a token first — see Authentication.
Connect
Open a WebSocket to the production endpoint, with your token on the handshake. One connection carries every topic you subscribe to.
Authenticate
Market data is moving its sign-in from a message to the handshake. Until the move completes, send your token as a message too, once the socket is open:
Subscribe as soon as either of these arrives — the acknowledgement, which echoes your reqId,
or the frame that opens a session signed in on its handshake:
A session that opened on its handshake answers the message
{"op": "error", "success": false, "error": "unknown_op"}: ignore it. A token that does not
verify is refused either way — "success": false with "error": "invalid_token" on the
message, or HTTP 401 on the handshake, before any socket opens.
The same in Python
What to know next
- Heartbeats. Every session receives a heartbeat carrying
streamAgeMs, the stream-freshness floor: it tells a quiet market from a stalled stream. - Falling behind. A session that cannot keep up is disconnected, not throttled. Reconnect,
authenticate and subscribe again: a latest-image topic such as
tobpushes its current image when you subscribe, and a synced book its snapshot. - Books. A book topic may answer
syncingrather thanlive: its snapshot arrives the moment the book is synced. A stale marker means the book cannot be trusted until the restatement that follows it. - Conflation. Append a conflation tier to a topic to receive it at a fixed cadence rather than every update — the tiers, every channel and every frame are in the Market Data WebSocket reference.