Order updates WebSocket
GET{BASE_URL}/websocket
wss://{BASE_URL}/websocket
Streams real-time updates for every Hong Kong order whose receiving initiator is your API key's initiator, across all of your accounts. Updates are not filtered by account.
Connecting
- Send
X-API-KEYas a header on the upgrade request; there is no query-string key. A missing or invalid key gets401before the upgrade. A request whoseOriginheader does not match the API host is rejected with403, so browsers cannot connect directly. - You may open several connections with the same key. Every connection receives every update.
- The stream is receive-only. Any text or binary message sent by the
client closes the connection with status
1008(policy violation). - The server sends a WebSocket ping every 30 seconds. Standard clients reply automatically.
Messages
Every frame is a text frame with message_type: order_update (schema
hk_websocket_message). message.order has the same shape as
GET /orders/status, but order.status is the status at the time of
the event.
order_event | Sent when | order.status | Extra fields |
|---|---|---|---|
new | The order was accepted (201). | new | |
partial_fill | A fill leaves quantity open. | partially_filled | last_qty, last_px |
fill | A fill completes the order. | filled | last_qty, last_px |
canceled | The order was canceled. | canceled or canceled_after_partial_fill | text if a reason is recorded |
rejected | The order was rejected after it was accepted. | rejected or rejected_after_partial_fill | text |
replaced | A modify took effect. order is the replacement; order.orig_order_id is the replaced order. | replaced or replaced_after_partial_fill | |
cancel_rejected | A cancel request failed; the order keeps working. | current status | text |
replace_rejected | A modify request failed. order is the rejected replacement; the original keeps working. | status of the original order | text |
pending_cancel, pending_replace and stopped are never sent here.
A request that fails synchronously (a 4xx/5xx HTTP response) does
not produce a rejected message. When an order is canceled after a
partial fill you receive partial_fill followed by canceled with
status canceled_after_partial_fill.
Top-level text has the form <error_code>: <message>
(Misc_Error: ... when the venue's reason has no Atomic Vaults code).
order.text holds the raw reason stored on the order.
Delivery
- Messages are delivered only to connections open at that moment.
There is no replay and no sequence number; after reconnecting,
reconcile with
GET /orders. - Messages for the same order are sent in event order.
- Each connection buffers up to 1,000 messages; beyond that, messages for a slow connection are dropped.
Responses
- 101
- 401
- 403
- default
Switching Protocols. The WebSocket is open.
Missing or invalid X-API-KEY.
Origin header does not match the API host. Plain-text body.
Text frames sent after the upgrade.