Skip to main content

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

  1. 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.
  2. 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

wss://ws.futurescw.com/perpum

Frequency Limit

The frequency limit for this subscription is 30 requests/2s per IP.

Subscription Parameters

ParameterMandatoryTypeDescription
eventtrueStringSubscribe or unsubscribe. sub: subscribe; unsub: unsubscribe.
Note: This parameter is case-sensitive.
paramstrueJsonRequested parameter objects, including:
-biztrueStringSpecifies the channel, e.g., "futures".
-typetrueStringDefines the function type, e.g., "order".

Response Parameters

ParameterTypeDescription
bizStringSpecifies the channel, e.g., "futures".
typeStringDefines the function type, e.g., "order".
resultbooleanIndicates whether the subscription or unsubscription was successful: true, false.
channelStringSpecifies the action performed: subscribe or unsubscribe.
pairCodeStringBase currency of the instrument, i.e., BTC
dataJsonData object, containing the following fields:
-currentPieceStringCurrent number of contracts
-leverageIntegerPosition leverage
-originalTypeStringOriginal order type
-contractTypeStringContract type :
1: Perpetual contract
-frozenFeeStringFrozen order fee
-orderStatusStringOrder status:
unFinish: unfulfilled,
part: partially filled,
Finish: fully filled,
Cancel: cancelled
-instrumentStringBase currency of the instrument, e.g., "BTC".
-quantityUnitIntegerSpecifies 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)
-sourceStringSource:api/web
-updatedDateLongTimestamp of the last order update.
-positionModelIntegerPosition margin mode :
0: Isolated margin,
1: Cross margin
-posTypeStringPosition type:plan/planTrigger/execute
-baseSizeStringOrder size in base currency.
-liquidateByStringOpening and closing event types
-makerFeeStringMaker fee
-totalPieceStringTotal number of contracts
-orderPriceStringOrder price specified by user
-idStringOrder ID
-directionStringTrade direction: long /short
-marginStringMargin used for the position.
-indexPriceStringLatest index price
-quantityStringSpecifies 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)
-takerFeeStringTaker fee
-userIdStringContract account User ID
-createdDateLongOrder creation timestamp.
-positionMarginStringPosition margin
-statusStringStatus: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'}.....