Position
Subscribe to the position stream to see changes to your position data in real-time.
Topic: position
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 |
> side | string | Position side. Buy ,Sell |
> size | string | Position size |
> positionIdx | integer | Used to identify positions in different position modes |
> tradeMode | integer | Trade mode
|
> positionValue | string | Position value |
> riskId | integer | Risk limit ID. |
> riskLimitValue | string | Risk limit value corresponding to riskId. |
> entryPrice | string | Entry price |
> markPrice | string | Mark price |
> leverage | string | Leverage. |
> positionBalance | string | Position margin. |
> autoAddMargin | integer | Whether to add margin automatically. 0 : false, 1 : true. |
> positionMM | string | Position maintenance margin. |
> positionIM | string | Position initial margin. |
> liqPrice | string | Position liquidation price, it is the real price for isolated and cross positions. |
> bustPrice | string | Est.bankruptcy price. |
> tpslMode | string | Depreciated, meaningless here, always "Full". |
> takeProfit | string | Take profit price |
> stopLoss | string | Stop loss price |
> trailingStop | string | Trailing stop |
> unrealisedPnl | string | Unrealised profit and loss |
> cumRealisedPnl | string | Cumulative realised PnL |
> positionStatus | string | Position status. Normal , Liq , Adl |
> adlRankIndicator | integer | Auto-deleverage rank indicator. What is Auto-Deleveraging? |
> createdTime | string | Position created timestamp (ms) |
> updatedTime | string | Position data updated timestamp (ms) |
Subscribe Example
{
"op": "subscribe",
"args": [
"position"
]
}
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": ['position']}));
});
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": "59232430b58efe-5fc5-4470-9337-4ce293b68edd",
"topic": "position",
"creationTime": 1672364174455,
"data": [
{
"positionIdx": 0,
"tradeMode": 0,
"riskId": 41,
"riskLimitValue": "200000",
"symbol": "XRPUSDT",
"side": "Buy",
"size": "75",
"entryPrice": "0.3615",
"leverage": "10",
"positionValue": "27.1125",
"positionBalance": "0",
"markPrice": "0.3374",
"positionIM": "2.72589075",
"positionMM": "0.28576575",
"takeProfit": "0",
"stopLoss": "0",
"trailingStop": "0",
"unrealisedPnl": "-1.8075",
"cumRealisedPnl": "0.64782276",
"createdTime": "1672121182216",
"updatedTime": "1672364174449",
"tpslMode": "Full",
"liqPrice": "",
"bustPrice": "",
"category": "linear",
"positionStatus": "Normal",
"adlRankIndicator": 2
}
]
}