Market order book
Streams the live order book for one market: two sides, bid and offer, each a ladder of price levels carrying size, liquidity and cumulative depth, so you can read how far the market goes without summing levels yourself. It pushes when the book changes, at most once every 200 ms, not on a timer; see Server pushes below for what arrives and when.
The channels under Channels carry your orders, fills and positions. This one carries the market: the full aggregated book and the market record, one market per topic.
One channel per market. Join market:<market_id> for each market you are
watching or trading, and join market_updates
alongside it if you also want lightweight change notifications across many
markets at once.
Joining
Section titled “Joining”The topic accepts either the market UUID or its symbol:
["1","1","market:1eb49edd-9bf0-4e86-8971-f8a19ff44b7d","phx_join",{}]["1","1","market:STXNBA-26OCT211900ATLORL-PRAORLNALEXANDERWALKER493112-25.5","phx_join",{}]Unlike the market_updates channel, a successful join replies with the
current state immediately: you do not have to ask for a snapshot first:
Captured on US demo, trimmed to a few of the market record’s fields:
["1","1","market:1eb49edd-9bf0-4e86-8971-f8a19ff44b7d","phx_reply", {"status":"ok","response":{ "market_id":"1eb49edd-9bf0-4e86-8971-f8a19ff44b7d", "symbol":"STXNBA-26OCT211900ATLORL-PRAORLNALEXANDERWALKER493112-25.5", "status":"open", "trading":true, "price":48.5, "max_price":100, "event_start":1792623600000000, "bids":[{"quantity":652,"price":46},{"quantity":1111,"price":45}], "offers":[{"quantity":1063,"price":53},{"quantity":612,"price":51}], "ob":{"b":[{"tl":299.92,"p":0.46,"q":652.0,"tc":652.0,"l":299.92},{"tl":799.87,"p":0.45,"q":1111.0,"tc":1763.0,"l":499.95}], "o":[{"tl":312.12,"p":0.51,"q":612.0,"tc":612.0,"l":312.12},{"tl":875.51,"p":0.53,"q":1063.0,"tc":1675.0,"l":563.39}]} }}]The reply is the full market record, the same shape the markets channel sends, with ob added. The two parts use different units: the market record’s prices are in cents (46), while ob is in dollars (0.46). Read each field’s units from its own page. event_start here is an integer of Unix microseconds, where GET /api/v1/markets returns the same instant as an ISO 8601 string ("2026-10-21T23:00:00.000000Z").
The record’s own bids and offers are ordered as over REST: both by price, highest first, so the best offer is the last entry of offers (51 above), not the first. ob is ordered best first on both sides, so there the best offer is ob.o[0] (0.51).
A market with no resting orders still joins, and its reply carries an empty book: "ob":{"b":[],"o":[]}.
A join is refused with a reason you can act on:
reason |
Meaning |
|---|---|
market_not_found |
No market with that id or symbol |
market_not_joinable |
The market exists but is not in a joinable status |
Joinable statuses are pre_open, open, closed and cancelled. scheduled
markets are hidden and cannot be joined. resulted and voided are terminal:
the socket receives one final market_update and is then dropped by the
server, so treat an unexpected close on this channel as “the market ended”,
not as a network fault.
Server pushes
Section titled “Server pushes”order_book_update
Section titled “order_book_update”The aggregated book, pushed when it changes, at most once every 200 ms. Changes inside that window are coalesced into one push. This is not a timer: a market whose book is quiet sends nothing, for minutes at a time, and an empty book can stay silent indefinitely. A push can also repeat the levels you already hold. Treat each push as the whole current book and replace what you hold.
The join reply already carries the book, so there is no separate push on join. On US demo, over five minutes, a market with a two-sided book from the house market maker sent its first order_book_update 32 seconds after the join, with the same levels as the reply, and then six within three seconds while the maker re-quoted. A market with an empty book sent none in six minutes. The first push:
[null,null,"market:1eb49edd-9bf0-4e86-8971-f8a19ff44b7d","order_book_update", {"ob":{"b":[{"tl":299.92,"p":0.46,"q":652.0,"tc":652.0,"l":299.92},{"tl":799.87,"p":0.45,"q":1111.0,"tc":1763.0,"l":499.95},{"tl":1549.63,"p":0.44,"q":1704.0,"tc":3467.0,"l":749.76},{"tl":2549.62,"p":0.41,"q":2439.0,"tc":5906.0,"l":999.99},{"tl":3749.26,"p":0.39,"q":3076.0,"tc":8982.0,"l":1199.64}], "o":[{"tl":312.12,"p":0.51,"q":612.0,"tc":612.0,"l":312.12},{"tl":875.51,"p":0.53,"q":1063.0,"tc":1675.0,"l":563.39},{"tl":1755.71,"p":0.54,"q":1630.0,"tc":3305.0,"l":880.2},{"tl":3028.03,"p":0.56,"q":2272.0,"tc":5577.0,"l":1272.32},{"tl":4754.37,"p":0.59,"q":2926.0,"tc":8503.0,"l":1726.34}]}}]b is the bid side, o the offer side, each best first: bids from the highest price down, offers from the lowest up. Each level:
| Field | Meaning |
|---|---|
p |
Price, in dollars |
q |
Contracts available at this price |
l |
Liquidity at this price, in dollars |
tc |
Total contracts at this price and better |
tl |
Total liquidity at this price and better, in dollars |
These are JSON numbers, not the dollar strings the REST API and the
orderbook topic send.
tc and tl are cumulative, so you can read depth-to-price straight off a
level without summing the ones above it.
market_update
Section titled “market_update”The full Market map, pushed whenever the market changes, status
transitions, trading halts, settlement. Same shape the
markets channel delivers.
Re-syncing after a reconnect
Section titled “Re-syncing after a reconnect”Send request_snapshot and the server immediately re-pushes both the current
order_book_update and market_update:
["1","2","market:1eb49edd-9bf0-4e86-8971-f8a19ff44b7d","request_snapshot",{}]On a market with an empty book the snapshot is an empty book, {"ob":{"b":[],"o":[]}}, followed by the market_update.
Do this after any reconnect. There is currently no sequence number on
order_book_update, so a client cannot detect a gap while it believes itself
connected. If you suspect you have missed data, call request_snapshot and
replace your book with what comes back rather than trying to reconcile.
Authentication
Section titled “Authentication”This channel carries no account-specific data, so it accepts an unsigned
socket. The handshake still needs a User-Agent header, or it is refused with
403. Your account channels need a signed socket: if you also want your own
orders and fills, sign the handshake as described in
WebSocket channels and join both on that one connection.
An OAuth app token works too: send it in the x-stx-oauth-token handshake header instead of the signature headers (see Market data). The token needs market_data; without it the join is refused:
["1","1","market:1eb49edd-9bf0-4e86-8971-f8a19ff44b7d","phx_reply",{"status":"error","response":{"reason":"insufficient_scope"}}]
