Skip to main content

Position

Subscribe to the position stream to see changes to your position data in real-time.

Topic: position

Response Parameters

ParameterTypeComments
idstringMessage ID
topicstringTopic name
creationTimenumberData created timestamp (ms)
dataarrayObject
> categorystringProduct type
> symbolstringSymbol name
> sidestringPosition side. Buy,Sell
> sizestringPosition size
> positionIdxintegerUsed to identify positions in different position modes
> tradeModeintegerTrade mode
  • USDT perpetual & Inverse contract: 0: cross-margin, 1: isolated margin
> positionValuestringPosition value
> riskIdintegerRisk limit ID.
> riskLimitValuestringRisk limit value corresponding to riskId.
> entryPricestringEntry price
> markPricestringMark price
> leveragestringLeverage.
> positionBalancestringPosition margin.
> autoAddMarginintegerWhether to add margin automatically. 0: false, 1: true.
> positionMMstringPosition maintenance margin.
> positionIMstringPosition initial margin.
> liqPricestringPosition liquidation price, it is the real price for isolated and cross positions.
> bustPricestringEst.bankruptcy price.
> tpslModestringDepreciated, meaningless here, always "Full".
> takeProfitstringTake profit price
> stopLossstringStop loss price
> trailingStopstringTrailing stop
> unrealisedPnlstringUnrealised profit and loss
> cumRealisedPnlstringCumulative realised PnL
> positionStatusstringPosition status. Normal, Liq, Adl
> adlRankIndicatorintegerAuto-deleverage rank indicator. What is Auto-Deleveraging?
> createdTimestringPosition created timestamp (ms)
> updatedTimestringPosition 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
}
]
}