Choose channels
Use the exact symbol returned by
GET /markets.
Private account updates
Portfolio snapshots are pushed onaccount:<userId>. The channel is private, so the connection must present a single-use ticket instead of your session cookie.
- Call
POST /v1/auth/ws-ticketfrom your signed-in frontend session. - Read
ticketfrom the201response. It expires after 60 seconds and works once. - Connect to
wss://api.paperdrill.dev/?ticket=TICKET.
account:<userId> channel, and sends an acknowledgement:
SUBSCRIBE for your own account channel. Asking for a different user’s private channel returns:
Snapshot shape
10 ** quotePrecision and quantity fields by 10 ** qtyPrecision. at, lastBuyAt, and lastSellAt are Unix milliseconds.
Snapshots are sent after fills and balance changes with a short debounce, then at most every five minutes while positions are open. Fetch GET /portfolio once for initial state, then apply snapshots as replacements.
Leaderboard updates
The publicleaderboard channel announces that live standings changed. Subscribe without a ticket. Messages are lightweight invalidation signals, not full standings:
GET /leaderboard when a message arrives. The server debounces bursts, so clients should debounce refetches too. Rankings are computed from the same live account snapshots; there is no polling interval to mirror.
Subscribe
Send oneSUBSCRIBE message after the connection opens. One message can contain multiple channels.
UNSUBSCRIBE.
Interpret messages
Trades
Tickers and candles
Ticker messages use the same shape as the REST ticker. Candle messages containtime, symbol, open, high, low, close, volume, and event: "candle".
Depth
Depth messages contain only changed levels. Follow the snapshot-and-buffer procedure in Maintain a local order book; do not treat one depth message as a complete book.Reconnect safely
Connections can close during a deployment or network interruption. Reconnect with exponential backoff and jitter, then resubscribe to every desired channel.GET /portfolio if the gap is long enough that the last snapshot may be stale.