This page will help you get started with "orders" channel

Channel: orders

Before subscribing to this channel, authentication is required.

The orders channel provides updates on all orders across all markets. Upon subscription, you receive one snapshot of the orders. Afterward, real-time updates are streamed to you whenever there are changes to your orders.

The update response includes an extra field called last_trades, which shows the trades in the most recent events:

  • The snapshot response doesn't include this field because it's not about the latest event.
  • If an order is canceled, the update response doesn't include this field since cancellation events don't involve trades.
  • If an order is fully filled, the response includes this field because trades occurred, completing the order.
// Request
{
  "op": "sub",
  "channel": "orders"
}
// Response - SNAPSHOT
// the order's format should be the same with the REST api about order
{
  "channel": "orders",
  "type": "snapshot",
  "data": [
    {
      "avg_price": "0",
      "cancel_reason": "",
      "cancel_reject_reason": "",
      "cancel_requested": false,
      "cancel_requested_at": "0",
      "client_order_id": "",
      "created_at_ts": "1719319405611080236",
      "filled_fees": "0",
      "filled_size": "0",
      "id": "6cb26475-a6df-404a-b00c-3ebc2e8fc846",
      "initial_margin": "54.9528381846000009",
      "is_liquidation": false,
      "last_trades": [],
      "nonce": "1719319405354011720",
      "order_stop_type": "STOP_NONE",
      "post_only": false,
      "price": "55000",
      "product_id": "BTC-PERP",
      "reduce_only": false,
      "reject_reason": "",
      "sender": "0xa01f2319baf9e8a344486ebafa96fb3c9f5bda05",
      "side": "BUY",
      "size": "0.018",
      "status": "OPEN",
      "stop_price": "0",
      "stp": "CANCEL_TAKER",
      "time_in_force": "GTC",
      "type": "LIMIT",
      "updated_at": "1719319405611080236"
    },
    {
      "avg_price": "70000",
      "cancel_reason": "",
      "cancel_reject_reason": "",
      "cancel_requested": false,
      "cancel_requested_at": "0",
      "client_order_id": "",
      "created_at_ts": "1718911292630380000",
      "filled_fees": "-0.0385",
      "filled_size": "0.011",
      "id": "b83f7c94-8779-4089-b15f-58e3d40cdfed",
      "initial_margin": "9.15880636410000015",
      "is_liquidation": false,
      "last_trades": [],
      "nonce": "1718911292249923774",
      "order_stop_type": "STOP_NONE",
      "post_only": false,
      "price": "70000",
      "product_id": "BTC-PERP",
      "reduce_only": false,
      "reject_reason": "",
      "sender": "0xa01f2319baf9e8a344486ebafa96fb3c9f5bda05",
      "side": "SELL",
      "size": "0.014",
      "status": "OPEN",
      "stop_price": "0",
      "stp": "CANCEL_TAKER",
      "time_in_force": "GTC",
      "type": "LIMIT",
      "updated_at": "1719249149768837378"
    },
    {
      "avg_price": "3000",
      "cancel_reason": "",
      "cancel_reject_reason": "",
      "cancel_requested": false,
      "cancel_requested_at": "0",
      "client_order_id": "",
      "created_at_ts": "1718859866862498000",
      "filled_fees": "-0.03",
      "filled_size": "0.2",
      "id": "f9d68224-5127-4dc6-98f6-037f7f178c67",
      "initial_margin": "5.0493477974999985",
      "is_liquidation": false,
      "last_trades": [],
      "nonce": "1718859866425486599",
      "order_stop_type": "STOP_NONE",
      "post_only": false,
      "price": "3000",
      "product_id": "ETH-PERP",
      "reduce_only": false,
      "reject_reason": "",
      "sender": "0xa01f2319baf9e8a344486ebafa96fb3c9f5bda05",
      "side": "BUY",
      "size": "0.23",
      "status": "OPEN",
      "stop_price": "0",
      "stp": "CANCEL_TAKER",
      "time_in_force": "GTC",
      "type": "LIMIT",
      "updated_at": "0"
    },
    {
      "avg_price": "0",
      "cancel_reason": "",
      "cancel_reject_reason": "",
      "cancel_requested": false,
      "cancel_requested_at": "0",
      "client_order_id": "",
      "created_at_ts": "1718859847456358000",
      "filled_fees": "0",
      "filled_size": "0",
      "id": "572c6d1f-cb3d-4db2-8328-d164017bbfaf",
      "initial_margin": "0",
      "is_liquidation": false,
      "last_trades": [],
      "nonce": "1718859847142017325",
      "order_stop_type": "STOP_LOSS",
      "post_only": false,
      "price": "197.89",
      "product_id": "SOL-PERP",
      "reduce_only": true,
      "reject_reason": "",
      "sender": "0xa01f2319baf9e8a344486ebafa96fb3c9f5bda05",
      "side": "BUY",
      "size": "8.8",
      "status": "STOP_ACCEPTED",
      "stop_price": "196.91",
      "stp": "CANCEL_TAKER",
      "time_in_force": "IOC",
      "type": "STOP",
      "updated_at": "0"
    }
  ],
  "timestamp": "1719319688307036691" // unix timestamp when this snapshot is created
}
// Response - update
// the API format is the same with the snapshot. In each update, the server might returns multiple changed orders
{
  "channel": "orders",
  "type": "update",
  "data": [
    {
      "avg_price": "0",
      "cancel_reason": "",
      "cancel_reject_reason": "",
      "cancel_requested": false,
      "cancel_requested_at": "0",
      "client_order_id": "",
      "created_at_ts": "1719319688307036691",
      "filled_fees": "0",
      "filled_size": "0",
      "id": "a01292c9-00f1-4c18-9d47-ec18df88d0ae",
      "initial_margin": "54.9516550639499991",
      "is_liquidation": false,
      "last_trades": [],
      "nonce": "1719319688044650011",
      "order_stop_type": "STOP_NONE",
      "post_only": false,
      "price": "55000",
      "product_id": "BTC-PERP",
      "reduce_only": false,
      "reject_reason": "",
      "sender": "0xa01f2319baf9e8a344486ebafa96fb3c9f5bda05",
      "side": "BUY",
      "size": "0.018",
      "status": "PENDING",
      "stop_price": "0",
      "stp": "CANCEL_TAKER",
      "time_in_force": "GTC",
      "type": "LIMIT",
      "updated_at": "1719319688307036691"
    }
  ],
  "timestamp": "1719319688307036691" // unix timestamp when this event is emitted, should be the same with order's updated_at
}
// Response - update
// the API format is the same with the snapshot. In each update, the server might returns multiple changed orders
{
  "channel": "orders",
  "type": "update",
  "data": [
    {
      "avg_price": "0",
      "cancel_reason": "",
      "cancel_reject_reason": "",
      "cancel_requested": false,
      "cancel_requested_at": "0",
      "client_order_id": "",
      "created_at_ts": "1719319688307036691",
      "filled_fees": "0",
      "filled_size": "0",
      "id": "a01292c9-00f1-4c18-9d47-ec18df88d0ae",
      "initial_margin": "54.9516550639499991",
      "is_liquidation": false,
      "last_trades": [],
      "nonce": "1719319688044650011",
      "order_stop_type": "STOP_NONE",
      "post_only": false,
      "price": "55000",
      "product_id": "BTC-PERP",
      "reduce_only": false,
      "reject_reason": "",
      "sender": "0xa01f2319baf9e8a344486ebafa96fb3c9f5bda05",
      "side": "BUY",
      "size": "0.018",
      "status": "OPEN",
      "stop_price": "0",
      "stp": "CANCEL_TAKER",
      "time_in_force": "GTC",
      "type": "LIMIT",
      "updated_at": "1719319688307036691"
    }
  ],
  "timestamp": "1719319688307036691" // unix timestamp when this event is emitted, should be the same with order's updated_at
}
// return when sub orders is sent without authentication
{
  "channel": "orders",
  "type": "error",
  "message": "not authenticated",
  "code": 401
}

๐Ÿ“˜

Orders

Check out Get an order response for the order struct returned from this endpoint and Matching Engine for what various order statuses mean.