Real-Time Data via WebSocket

Connect, authorize, subscribe, and decode market-data events.

View as Markdown

Market data streams over a WebSocket on a dedicated host. The low-level wire protocol — frame types, request framing, heartbeats, and market replay — is the same one the trading API uses, so see the Trade API Real-Time Data via WebSocket guide for the full protocol. This page covers what’s specific to market data.

Connect and Authorize

Open a WebSocket to the market-data host and authorize it once with your mdAccessToken (see Authentication & Access):

wss://md-demo.tradovateapi.com/v1/websocket

Subscribe and Stream

Send a subscription request — for example md/subscribeQuote with a symbol — and the server streams matching events until you unsubscribe. Each subscription returns a subscription ID; cache it so you can unsubscribe later. The WebSocket API reference documents every channel and message, and the Market Data overview walks the end-to-end flow.

Market Data Events

Market data arrives as event frames inside a[...] array frames:

  • e: "md" — quote, DOM, and histogram updates, carried in d.quotes, d.doms, or d.histograms.
  • e: "chart" — bar and tick chart packets, carried in d.charts.

For example, a quote event:

1{
2 "e": "md",
3 "d": {
4 "quotes": [
5 {
6 "timestamp": "2021-04-13T04:59:06.588Z",
7 "contractId": 123456,
8 "entries": {
9 "Bid": { "price": 4205.25, "size": 12 },
10 "Offer": { "price": 4205.50, "size": 8 },
11 "Trade": { "price": 4205.25, "size": 3 }
12 }
13 }
14 ]
15 }
16}

A server that’s actively streaming won’t send heartbeats, so your client must send a heartbeat every 2.5 seconds to keep the connection alive. See Client Heartbeats in the protocol guide.