wss://api.backquant.com/v2/ws/options
Single connection, multiple subscriptions. The same canonical trade payload from the REST tape, pushed sub-second after the upstream venue emits it.
Authentication
Pass your API key on the WebSocket handshake — either of:- Query parameter —
wss://api.backquant.com/v2/ws/options?api_key=bq_live_...(easiest from browsers). Authorization: Bearerheader — preferred from server-to-server clients.X-API-Keyheader — accepted as a fallback for clients that can set arbitrary handshake headers.
1008 policy-violation code and a human-readable reason.
Channel inventory
| Channel | Payload | Frequency |
|---|---|---|
tape.{coin}.{venue} | One trade per frame | Per trade (~10–100/s in burst) |
tape.{coin}.agg | Same trade payload, aggregated across all venues for that coin | Per trade |
status.heartbeat | Server liveness + per-client queue stats | Every 15 s |
{coin} is BTC or ETH. {venue} is deribit, bybit, okx, or binance (case-insensitive on subscribe; the server normalises to lowercase). See Tape overview → Venue coverage for what each venue ships.
Max 32 channels per connection.
Protocol
Server → client envelope
Every server frame is a JSON object with anevent field:
Client → server commands
Trade payload
premium_usd is the field to rank, filter or score by — venue quotation differences are already normalised away.
Connection lifecycle
- Connect with API key → server validates → counts connection against your per-tier cap.
- Receive
welcome→ sanity-checksubscription_tierandavailable_channels. - Send
subscribe→ server replies withsubscribedack + immediately starts streaming matching trades. - Stream — trades arrive on their channel;
status.heartbeatarrives every 15 s if subscribed. - Heartbeat liveness — the server expects at least one client frame (subscribe / unsubscribe / ping) within 60 s. Otherwise it closes with code
1001. - Slow consumer — each client has a 1000-message send buffer. If full for > 5 s the server sends a
slow_consumerevent then closes with code1013. Reduce your subscription set or process frames faster. - Disconnect → connection counter decrements; reconnect any time.
Per-tier connection caps
| Tier | Concurrent WS connections per API key |
|---|---|
| API Monthly | 2 |
| API Yearly | 4 |
| Enterprise | 10 (customisable) |
1008 with Connection cap reached for tier 'X' (max N).
Reconnect template
The server has no replay —$ cursor is used on the underlying Redis stream, so a reconnect resumes with whatever’s live, not whatever you missed. For zero-gap consumers, also poll /v2/tape?after=<last_ts> on reconnect to fetch trades that arrived during the gap.
scripts/v2_ws_demo/ws_tape_demo.py.
