Skip to main content

Wallet

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

Topic: wallet

Response Parameters

ParameterTypeComments
idstringMessage ID
topicstringTopic name
creationTimenumberData created timestamp (ms)
dataarrayObject
> accountTypestringAccount type.
  • Normal account: CONTRACT
> accountLTVstringAccount LTV: account total borrowed size / (account total equity + account total borrowed size).
> accountIMRatestringInitial Margin Rate: Account Total Initial Margin Base Coin / Account Margin Balance Base Coin.
> accountMMRatestringMaintenance Margin Rate: Account Total Maintenance Margin Base Coin / Account Margin Balance Base Coin.
> totalEquitystringEquity of account converted to usd:Account Margin Balance Base Coin + Account Option Value Base Coin.
> totalWalletBalancestringWallet Balance of account converted to usd:∑ Asset Wallet Balance By USD value of each asset。
> totalMarginBalancestringMargin Balance of account converted to usd:totalWalletBalance + totalPerpUPL.
> totalAvailableBalancestringAvailable Balance of account converted to usd:Regular mode:totalMarginBalance - totalInitialMargin.
> totalPerpUPLstringUnrealised P&L of perpetuals of account converted to usd:∑ Each perp upl by base coin.
> totalInitialMarginstringInitial Margin of account converted to usd:∑ Asset Total Initial Margin Base Coin.
> totalMaintenanceMarginstringMaintenance Margin of account converted to usd: ∑ Asset Total Maintenance Margin Base Coin.
> coinarrayObject
>> coinstringCoin name, such as BTC, ETH, USDT
>> equitystringEquity of current coin
>> usdValuestringUSD value of current coin. If this coin cannot be collateral, then it is 0
>> walletBalancestringWallet balance of current coin
>> availableToWithdrawstringAvailable amount to withdraw of current coin
>> accruedIntereststringAccrued interest
>> totalOrderIMstringPre-occupied margin for order.
>> totalPositionIMstringSum of initial margin of all positions + Pre-occupied liquidation fee.
>> totalPositionMMstringSum of maintenance margin for all positions.
>> unrealisedPnlstringUnrealised P&L
>> cumRealisedPnlstringCumulative Realised P&L

Subscribe Example

{
"op": "subscribe",
"args": [
"wallet"
]
}
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": ['wallet']}));
});

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

{
"topic": "wallet",
"id": "0df2a9a8-5975-4252-9f4f-2856b51f47f6",
"creationTime": 1696654328771,
"data": [
{
"accountType": "CONTRACT",
"accountIMRate": "",
"accountMMRate": "",
"accountLTV": "",
"totalEquity": "",
"totalWalletBalance": "",
"totalMarginBalance": "",
"totalAvailableBalance": "",
"totalPerpUPL": "",
"totalInitialMargin": "",
"totalMaintenanceMargin": "",
"coin": [
{
"coin": "USDT",
"equity": "9385500.84045358",
"usdValue": "",
"walletBalance": "9385525.87726358",
"availableToWithdraw": "9380099.99253585",
"borrowAmount": "",
"availableToBorrow": "",
"accruedInterest": "",
"totalOrderIM": "2326.584104",
"totalPositionIM": "3099.30062373",
"totalPositionMM": "",
"unrealisedPnl": "-25.03681",
"cumRealisedPnl": "-5983.07783642"
}
]
}
]
}