Execution
Subscribe to the execution stream to see your executions in real-time.
tip
You may have multiple executions for one order in a single message.
Topic: execution
All-In-One Topic: execution
Categorised Topic: execution.spot
, execution.linear
, execution.inverse
info
- All-In-One topic and Categorised topic cannot be in the same subscription request
- All-In-One topic: Allow you to listen to all categories (spot, linear, inverse) websocket updates
- Categorised Topic: Allow you to listen only to specific category websocket updates
Response Parameters
Parameter | Type | Comments |
---|---|---|
id | string | Message ID |
topic | string | Topic name |
creationTime | number | Data created timestamp (ms) |
data | array | Object |
> category | string | Product type
|
> symbol | string | Symbol name |
> orderId | string | Order ID |
> orderLinkId | string | User customized order ID |
> side | string | Side. Buy ,Sell |
> orderPrice | string | Order price. |
> orderQty | string | Order qty. |
> leavesQty | string | The remaining qty not executed. |
> orderType | string | Order type. Market ,Limit |
> stopOrderType | string | Stop order type. If the order is not stop order, any type is not returned. |
> execFee | string | Executed trading fee. |
> execId | string | Execution ID |
> execPrice | string | Execution price |
> execQty | string | Execution qty |
> execType | string | Executed type. |
> execValue | string | Executed order value. |
> execTime | string | Executed timestamp(ms) |
> isMaker | boolean | Is maker order. true : maker, false : taker |
> feeRate | string | Trading fee rate. |
> closedSize | string | Closed position size |
Subscribe Example
{
"op": "subscribe",
"args": [
"execution"
]
}
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": ['execution']}));
});
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": "592324803b2785-26fa-4214-9963-bdd4727f07be",
"topic": "execution",
"creationTime": 1672364174455,
"data": [
{
"category": "linear",
"symbol": "XRPUSDT",
"execFee": "0.005061",
"execId": "7e2ae69c-4edf-5800-a352-893d52b446aa",
"execPrice": "0.3374",
"execQty": "25",
"execType": "Trade",
"execValue": "8.435",
"isMaker": false,
"feeRate": "0.0006",
"leavesQty": "0",
"orderId": "f6e324ff-99c2-4e89-9739-3086e47f9381",
"orderLinkId": "",
"orderPrice": "0.3207",
"orderQty": "25",
"orderType": "Market",
"stopOrderType": "UNKNOWN",
"side": "Sell",
"execTime": "1672364174443",
"closedSize": ""
}
]
}