Subscribe Current Orders
API Description
This Websocket subscription provides real-time updates on all unfilled/filled orders across all instruments. The response includes details such as instrument, direction, quantity, quantity unit, margin, leverage, maker fee, taker fee, timestamp, etc.
Note: Current orders data is available via both RESTful and Websocket APIs. This page describes the Websocket API. For information on the RESTful API, please click here
Precautions
- The Websocket connection does not return any response unless new orders are placed after the connection is established. If no orders are placed, no updates will be received. Users should ensure that they have active trading activity to receive real-time order updates.
- This Websocket provides real-time update on all unfilled/filled orders across all instruments.
Authentication
This is a private Websocket and requires authentication. For details on using the Websocket API, please refer to Introduction > Authentication & Code Snippet > Futures > Websocket Private Interface.
Websocket URL
Frequency Limit
The frequency limit for this subscription is 30 requests/2s per IP.
Subscription Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| event | true | String | Subscribe or unsubscribe. sub: subscribe; unsub: unsubscribe. Note: This parameter is case-sensitive. |
| params | true | Json | Requested parameter objects, including: |
| -biz | true | String | Specifies the channel, e.g., "futures". |
| -type | true | String | Defines the function type, e.g., "order". |
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| biz | String | Specifies the channel, e.g., "futures". |
| type | String | Defines the function type, e.g., "order". |
| result | boolean | Indicates whether the subscription or unsubscription was successful: true, false. |
| channel | String | Specifies the action performed: subscribe or unsubscribe. |
| pairCode | String | Base currency of the instrument, i.e., BTC |
| data | Json | Data object, containing the following fields: |
| -currentPiece | String | Current number of contracts |
| -leverage | Integer | Position leverage |
| -originalType | String | Original order type |
| -contractType | String | Contract type : 1: Perpetual contract |
| -frozenFee | String | Frozen order fee |
| -orderStatus | String | Order status: unFinish: unfulfilled, part: partially filled, Finish: fully filled, Cancel: cancelled |
| -instrument | String | Base currency of the instrument, e.g., "BTC". |
| -quantityUnit | Integer | Specifies the unit for order size: 0: Denominated in the quote currency (e.g., USDT in BTC-USDT), 1: Denominated in number of contracts, 2: Denominated in the base currency (e.g., BTC in BTC-USDT) |
| -source | String | Source:api/web |
| -updatedDate | Long | Timestamp of the last order update. |
| -positionModel | Integer | Position margin mode : 0: Isolated margin, 1: Cross margin |
| -posType | String | Position type:plan/planTrigger/execute |
| -baseSize | String | Order size in base currency. |
| -liquidateBy | String | Opening and closing event types |
| -makerFee | String | Maker fee |
| -totalPiece | String | Total number of contracts |
| -orderPrice | String | Order price specified by user |
| -id | String | Order ID |
| -direction | String | Trade direction: long /short |
| -margin | String | Margin used for the position. |
| -indexPrice | String | Latest index price |
| -quantity | String | Specifies order size based on quantityUnit: If quantityUnit=0, the quantity is measured the quote currency (e.g., USDT in BTC-USDT), If quantityUnit=1, the quantity is measured in number of contracts, If quantityUnit=2, the quantity is measured in the base currency (e.g., BTC in BTC-USDT) |
| -takerFee | String | Taker fee |
| -userId | String | Contract account User ID |
| -createdDate | Long | Order creation timestamp. |
| -positionMargin | String | Position margin |
| -status | String | Status:open/close/cancel |
Subscription Example
The following Python code shows how to subscribe to current orders.
Note: For a complete code example, please refer to Introduction > Authentication & Code Snippet > Futures > Websocket Private Interface.
url= "wss://ws.futurescw.com/perpum"
subscription_payload = {"event": "sub",
"params": {"biz": "futures",
"type": "order"}}
api_key= "your_api_key"
sec_key = "your_sec_key"
FuturesWebsocketPrivate(url, subscription_payload, api_key, sec_key) # function FuturesWebsocketPrivate() is defined in section (Introduction > Authentication & Code Snippet > Futures > Websocket Private Interface)
Note: For a complete Java code example, please refer to Introduction > Authentication & Code Snippet > Futures > Websocket Private Interface.
Response Example
The Websocket subscription will keep updating the current orders in real-time. For brevity, only the initial response from above Python subscription is provided below:
{"biz":"futures","data":{"result":true},"channel":"subscribe","type":"order"}
{'biz': 'futures',
'pairCode': 'BTC',
'data': [{'currentPiece': '1',
'leverage': '1',
'originalType': 'plan',
'contractType': 1,
'fee': '0',
'frozenFee': '0.00954',
'orderStatus': 'unFinish',
'instrument': 'BTC',
'quantityUnit': 0,
'source': 'api',
'updatedDate': 1739955929000,
'positionModel': 0,
'posType': 'plan',
'baseSize': '0.001',
'liquidateBy': 'manual',
'makerFee': '0.0001',
'totalPiece': '1',
'orderPrice': '95400',
'id': '33308740320587027',
'direction': 'long',
'margin': '95.4',
'indexPrice': '95670.9',
'quantity': '100',
'takerFee': '0.0006',
'userId': '1162061',
'createdDate': 1739955929000,
'positionMargin': '95.4',
'status': 'open'}],
'type': 'order'}.....