Skip to main content

Order

Subscribe to the order stream to see changes to your orders in real-time.

All-In-One Topic: order
Categorised Topic: order.spot, order.linear, order.inverse

Response Parameters

ParameterTypeComments
idstringMessage ID
topicstringTopic name
creationTimenumberData created timestamp (ms)
dataarrayObject
> categorystringProduct type
  • Normal account: spot, linear, inverse.
> orderIdstringOrder ID
> orderLinkIdstringUser customised order ID
> symbolstringSymbol name
> pricestringOrder price
> qtystringOrder qty
> sidestringSide. Buy,Sell
> positionIdxintegerPosition index. Used to identify positions in different position modes
> orderStatusstringOrder status
> cancelTypestringCancel type
> rejectReasonstringReject reason.
> avgPricestringAverage filled price. If unfilled, it is ""
  • If a partially filled order, and the final orderStatus is Cancelled, then avgPrice is "0"
  • Classic Spot: not supported, always ""
> leavesQtystringThe remaining qty not executed.
> leavesValuestringThe remaining value not executed.
> cumExecQtystringCumulative executed order qty
> cumExecValuestringCumulative executed order value
> cumExecFeestringCumulative executed trading fee.
> timeInForcestringTime in force
> orderTypestringOrder type. Market,Limit. For TP/SL order, it means the order type after triggered
> stopOrderTypestringStop order type
> orderIvstringImplied volatility
> triggerPricestringTrigger price. If stopOrderType=TrailingStop, it is activate price. Otherwise, it is trigger price
> takeProfitstringTake profit price
> stopLossstringStop loss price
> tpslModestringTP/SL mode, Full: entire position for TP/SL. Partial: partial position tp/sl.
> tpLimitPricestringThe limit order price when take profit price is triggered
> slLimitPricestringThe limit order price when stop loss price is triggered
> tpTriggerBystringThe price type to trigger take profit
> slTriggerBystringThe price type to trigger stop loss
> triggerDirectionintegerTrigger direction. 1: rise, 2: fall
> triggerBystringThe price type of trigger price
> lastPriceOnCreatedstringLast price when place the order
> reduceOnlybooleanReduce only. true means reduce position size
> closeOnTriggerbooleanClose on trigger.
> placeTypestringPlace type
> createdTimestringOrder created timestamp (ms)
> updatedTimestringOrder updated timestamp (ms)

Subscribe Example

{
"op": "subscribe",
"args": [
"order"
]
}
var url = require('url');
var WebSocket = require('ws');
var crypto = require('crypto');
var endpoint = "wss://stream-testnet.zoomex.com/v3/private"
console.log('attempting to connect to WebSocket %j', endpoint);
var client = new WebSocket(endpoint);
const apiKey="XXXXXXXXX";
const apiSecret="XXXXXXXXX";
client.on('open', function () {
console.log('"open" event!');
console.log('WebSocket Client Connected');
const expires = new Date().getTime() + 10000;
const signature = crypto.createHmac("sha256", apiSecret).update("GET/realtime" + expires).digest("hex");
const payload={
op: "auth",
args: [apiKey, expires.toFixed(0), signature],
}
client.send(JSON.stringify(payload));
setInterval(()=>{client.ping()}, 30000);
client.ping();
client.send(JSON.stringify({"op": "subscribe", "args": ['order']}));
});

client.on('message', function (data) {
console.log('"message" event! %j', JSON.parse(Buffer.from(data).toString()));
});
client.on('ping', function (data, flags) {
console.log("ping received");
});
client.on('pong', function (data, flags) {
console.log("pong received");
});

Stream Example

{
"id": "5923240c6880ab-c59f-420b-9adb-3639adc9dd90",
"topic": "order",
"creationTime": 1672364262474,
"data": [
{
"symbol": "ETHUSDT",
"orderId": "5cf98598-39a7-459e-97bf-76ca765ee020",
"side": "Sell",
"orderType": "Market",
"cancelType": "UNKNOWN",
"price": "72.5",
"qty": "1",
"orderIv": "",
"timeInForce": "IOC",
"orderStatus": "Filled",
"orderLinkId": "",
"lastPriceOnCreated": "",
"reduceOnly": false,
"leavesQty": "",
"leavesValue": "",
"cumExecQty": "1",
"cumExecValue": "75",
"avgPrice": "75",
"blockTradeId": "",
"positionIdx": 0,
"cumExecFee": "0.358635",
"createdTime": "1672364262444",
"updatedTime": "1672364262457",
"rejectReason": "EC_NoError",
"stopOrderType": "",
"tpslMode": "",
"triggerPrice": "",
"takeProfit": "",
"stopLoss": "",
"tpTriggerBy": "",
"slTriggerBy": "",
"tpLimitPrice": "",
"slLimitPrice": "",
"triggerDirection": 0,
"triggerBy": "",
"closeOnTrigger": false,
"category": "linear",
"placeType": "price"
}
]
}