Order Operations
TL;DR
/v1/stream is the sole bidirectional WebSocket. Authenticate in-band, stream framed
order.place / order.cancel / order.modify requests and receive one reply
per frame, dispatched to the same intake and verification the REST endpoints
use. The same session carries orders, fills, and tree subscriptions,
short-lived-token refresh, and cancel-on-disconnect for market makers.Connect
login frame. Set cancel_on_disconnect in that frame:
Create it with the verified WebSocket factory returned by the same Node
transport that handles REST. A stock WebSocket does not authenticate the
engine’s self-signed, boot-scoped certificate.
Message format
Every frame is JSON, tagged byop. Requests may carry a request_id, which the
reply echoes so a client can correlate responses on the multiplexed socket.
Request frames
Reply frames
Every reply carries a per-connection monotonicseq (starting at 1) so a client
can detect a dropped frame.
Cancel-on-disconnect
When you login withcancel_on_disconnect: true, the engine tracks the orders
placed on this socket and, when the socket closes, cancels the ones still
resting. This protects a market maker that loses connectivity from leaving stale
quotes crossing.
You can also set an account-wide default so every socket gets the behavior
without setting it in each login: PUT /account/settings with
{ "cancel_on_disconnect_default": true }. An explicit login value overrides
the account default for that connection.
The teardown is a server-initiated cancel using each order’s own booked key. It
needs no client signature, because the order was placed on this authenticated
session and a cancel only un-rests an order (it never settles or moves funds).
Heartbeat
Send aping frame periodically to keep the connection live and detect a
half-open socket; the server replies pong. Transport-level WebSocket pings are
also answered.
Example
REST vs. WebSocket
For live order state and fill memos, subscribe to the Orders Channel
and Fills Channel on this same socket.