User Data(orders, trades, asset, positions)

All push channels are activated automatically after a successful login. No explicit subscription is required.


User data stream.

Response

Orders data:

Pushed whenever an order changes state (e.g. NEW → OPEN → PARTIALLY_FILLED → FILLED / CANCELLED). Each push reflects the latest snapshot of that order.

{
    "channel":"Orders",
    "instId":"BINANCE_PERP_ETH_USDT",
    "data":{
        "portfolioId":"1702884522340000",
        "orderId":"1703213979730000",
        "clientOrderId":"1703213979730000",
        "exchangeType":"BINANCE",
        "businessType":"PERP",
        "sym":"BINANCE_PERP_ETH_USDT",
        "limitPrice":"2346",
        "orderQty":"0.01",
        "quoteOrderQty":"0",
        "side":"BUY",
        "exchangeOrderType":"LIMIT",
        "timeInForce":"GTC",
        "executedQty":"0",
        "executedAmount":"0",
        "executedAvgPrice":"0",
        "lastExecutedQty":"0",
        "lastExecutedPrice":"0",
        "lastExecutedAmount":"0",
        "fee":"0",
        "orderState":"NEW",
        "updateAt":"1703213979731",
        "createAt":"1703213979731",
        "borrowAmount":"0",
        "borrowAsset":null,
        "reason":"",
        "action": "",
        "actionMsg": "", 
        "cancelType": "",
				"amendType": ""
    }
}

FieldTyperemark
channelStringChannel name:Orders
instIdStringTrading unique identifier, example: BINANCE_SPOT_BTC_USDT, BINANCE_PERP_BTC_USDT
If you want to know other trading unique identifiers, please go to the introduction page.
dataArrayData
>portfolioIdStringPortfolio ID
>orderIdStringOrder ID
>clientOrderIdStringCustomer defined order ID
>exchangeTypeStringExchange type(BINANCE, OKX)
>businessTypeStringBusiness type(SPOT, PERP)
>symStringTrading unique identifier, example: BINANCE_SPOT_BTC_USDT, BINANCE_PERP_BTC_USDT
If you want to know other trading unique identifiers, please go to the introduction page.
>limitPriceStringOrder price
>orderQtyStringOrder quantity, note: trading unit of OKX is the number of contracts/ trading unit of Binance is the number of coin
Note: The trading unit on OKX is measured in the number of contracts, while the trading unit on Binance is measured in the number of coins.
>quoteOrderQtyStringOrder quote quantity, applicable only for spot market buy orders.
>sideStringSide(BUY,SELL)
>exchangeOrderTypeStringExchange order type(LIMIT, MARKET)
>timeInForceStringDefault GTC, enums:GTC,IOC,FOK,GTX
>executedQtyStringTransaction quantity
Note: The trading unit on OKX is measured in the number of contracts, while the trading unit on Binance is measured in the number of coins.
>executedAmountStringTransaction amount
>executedAvgPriceStringAverage transaction price
>lastExecutedQtyStringLast transaction quantity
>lastExecutedPriceStringLast transaction price
>lastExecutedAmountStringLast transaction amount
>feeStringExecuted transaction fee
>orderStateStringOrder state(NEW, OPEN, CANCELLED, FILLED, PARTIALLY_FILLED, REJECT, FAIL)
>updateAtStringUpdate time
>createAtStringCreate time
>reasonStringFail reason
>borrowAmountStringBorrow amount
>borrowAssetStringBorrow asset
>actionStringAMEND_PENDING
AMEND_COMPLETED
AMEND_FAILED
CANCEL_PENDING
CANCEL_COMPLETE
CANCEL_FAILED
>actionMsgStringaction msg
>cancelTypeStringUSER
EXPIRE
REDUCE_ONLY
LIQUIDATING
SYSTEM
SYM_DELIST
>amendTypeStringUSER
REDUCE_ONLY

Trades data:

Pushed for each individual fill event. A single order may generate multiple Trades pushes if it is filled in multiple transactions.

{
    "channel":"Trades",
    "instId":"OKX_PERP_BTC_USDT",
    "data":{
        "transactionId":"1703832204600001",
        "portfolioId":"1702884522340000",
        "orderId":"1703832204506000",
        "clientOrderId":"100001",
        "sym":"OKX_PERP_BTC_USDT",
        "exchangeType":"OKX",
        "businessType":"PERP",
        "price":"42703.4",
        "quantity":"1",
        "tradingFee":"0.0640551",
        "tradingFeeCoin":"USDT",
        "side":"SELL",
        "createAt":"1703832204600",
        "execType":"TAKER"
    }
}
FieldTyperemark
channelStringChannel name:Trades
instIdStringTrading pair unique identifier, example: BINANCE_SPOT_BTC_USDT, BINANCE_PERP_BTC_USDT
dataArrayData
>transactionIdStringTransaction ID
>portfolioIdStringPortfolio ID
>orderIdStringOrder ID
>clientOrderIdStringCustomer defined order ID
>symStringTrading unique identifier, example: BINANCE_SPOT_BTC_USDT, BINANCE_PERP_BTC_USDT
>exchangeTypeStringExchange type (example: BINANCE,OKX)
>businessTypeStringBusiness type
>priceStringFilled price
>quantityStringFilled quantity, note: trading unit of OKX is the number of contracts/ trading unit of Binance is the number of coin
>tradingFeeStringTrading fee
>tradingFeeCoinStringTrading fee coin
>sideStringSide(BUY,SELL)
>createAtStringExecution time
>execTypeStringTAKER or MAKER

Asset data:

Pushed whenever the balance of any coin changes (e.g. after a fill, deposit, withdrawal, or funding fee). Each push covers only the coin(s) whose balance changed.

{
	"channel": "Assets",
	"data": [{
		"portfolioId": "1711075287090000",
		"coin": "USDT",
		"exchangeType": "OKX",
		"businessType": "UNI",
		"balance": "99.012100925",
		"equity": "99.012100925",
		"available": "99.012100925",
		"frozen": "0",
		"overdraw": "0",
		"marginValue": "96.536798401875",
		"debt": "0",
		"virtualBorrow": "0",
		"debtMargin": "0",
		"perpMargin": "0",
    "maxTransferable":"0",
    "equityValue":"0"
    "borrow":"0",
    "upnl":"0",
    "updateAt": "1711955466958",
    "balanceDelta": "0",
    "eventType": "trading",
    "loan": "20",
    "loanValue": "20",
    "netEquity": "109.598539562734535877",
    "netEquityValue": "109.598539562734535877",
    "netMarginValue": "106.858576073666172481"
	}]
}
FieldTyperemark
channelStringChannel name:Assets
dataArrayData
>portfolioIdStringPortfolio ID
>coinStringCoin
>exchangeTypeStringExchange type(example: BINANCE, OKX)
>businessTypeStringUNI
>balanceStringTransferable amount
>equityStringEquity
>availableStringAvailable
>frozenStringFrozen
>overdrawStringOverDraw
>debtStringDebt
>marginValueStringMargin value
>virtualBorrowStringVirtual Borrow
>debtMarginStringDebt Margin
>perpMarginStringPerp Margin
>maxTransferableStringMaximum transfer amount
>equityValueStringEquity value
>borrowStringBorrow
>upnlStringUnrealized Profit and Loss
>updateAtStringUpdate time
> balanceDeltaStringBalance change that triggered this push. "0" when the push is caused by a position or order event with no direct balance movement. Negative value indicates a deduction (e.g. fee charged)..
> eventTypeStringEvent that triggered this push. trading indicates a trade-related event.
> loanValueStringThis field is included only when loan > 0. loan × indexPrice
> netEquityStringThis field is included only when loan > 0. Asset equity minus loan.
> netEquityValueStringThis field is included only when loan > 0. netEquity × indexPrice
> netMarginValueStringThis field is included only when loan > 0. netEquityValue × discountRate

Positon data:

Pushed whenever a position changes (e.g. after a fill, funding fee, or mark price update). Each push is a full snapshot of the affected position.

{
    "channel":"Positions",
    "instId":"OKX_PERP_BTC_USDT",
    "data":{
        "portfolioId":"1702884522340000",
        "positionId":"1704179813908000",
        "sym":"OKX_PERP_BTC_USDT",
        "positionSide":"NET",
        "positionMargin":"226.586",
        "positionMM":"4.53172",
        "positionQty":"1",
        "positionValue":"453.172",
        "entryValue":"453.194",
        "unrealizedPNL":"-0.022",
        "unrealizedPNLRate":"-0.000097088664015851",
        "avgPrice":"45319.4",
        "markPrice":"45317.2",
        "leverage":"2",
        "maxLeverage":"20",
        "riskLevel":"1",
        "fee":"0.0679791",
        "fundingFee":"0",
        "createAt":"1704179813908",
        "updateAt":"1704179813908"
    }
}
FieldTyperemark
channelStringChannel name:Positions
dataArrayData
>portfolioIdStringPortfolio ID
>positionIdStringPosition ID
>symStringTrading unique identifier, example: BINANCE_PERP_BTC_USDT
>positionSideStringNET
>positionMarginStringPosition margin
>positionMMStringPosition maintain margin
>positionQtyStringPosition quantity, note: trading unit of OKX is the number of contracts/ trading unit of Binance is the number of coin
>positionValueStringPosition value
>entryValueStringPosition init value
>unrealizedPNLStringUnrealized PNL
>unrealizedPNLRateStringUnrealized PNL rate
>avgPriceStringAverage price
>markPriceStringMark price
>leverageStringLeverage
>maxLeverageStringMax leverage
>riskLevelStringRisk level
>feeStringTrading fee
>fundingFeeStringFunding fee
>createAtStringCreate time
>updateAtStringUpdate time

MarginCall data:

Pushed when the account's margin ratio approaches or crosses the liquidation threshold.

{
    "channel":"MarginCall",
    "data":{
        "portfolioId":"1702884522340000",
        "exchangeType":"OKX",
        "margin":"141.598333333333333333",
        "maintainMargin":"4.24795",
        "uniMMR":"-0.220583246036323403",
        "accountStatus":"LIQUIDATED",
        "updateAt":"1703834254274"
    }
}
FieldTyperemark
channelStringChannel name:MarginCall
dataArrayMargin call snapshot
>portfolioIdStringPortfolio ID
>exchangeTypeStringExchange this margin status applies to: BINANCE, OKX, EDX
>marginStringCurrent total margin balance of the account
>maintainMarginStringMinimum margin required across all positions to avoid liquidation
>uniMMRStringvalidMargin/maintainMargin.
Unified maintenance margin rate, used to measure risk, a forced liquidation is triggered when the value is below 100%.
>accountStatusStringCurrent account status: NORMAL (healthy), MARGIN_CALL (approaching liquidation threshold), LIQUIDATED (liquidation in progress)
>updateAtStringTimestamp of this update (milliseconds)

📘

MarginCall is the warning. Once liquidation actually starts, the Liquidation channels report every step of the process and every liquidation order.

Accounts

Push whenever the account status changes. Each push contains a full snapshot of the account information.

{
    "channel": "Accounts",
    "data": {
        "portfolioId": "2178424043067202",
        "exchangeType": "BINANCE",
        "equity": "135.997795254213646297",
        "marginValue": "126.3772437379809635842714751341",
        "frozenMargin": "7.972976138666666667",
        "perpMargin": "1.306309472",
        "debtMargin": "0",
        "openLossMargin": "0.002286041576",
        "validMargin": "126.3749576964049635842714751341",
        "availableMargin": "118.4019815577382969172714751341",
        "maintainMargin": "1.08491011568",
        "positionValue": "6.53154736",
        "uniMMR": "116.484265258413286347",
        "riskRatio": "0.0086",
        "accountStatus": "NORMAL",
        "upnl": "-0.01245264",
        "perpAvailableMargin": "118.4019815577382969172714751341",
        "createAt": "1782288534085",
        "updateAt": "1782732414466",
        "totalLoanValue": "20",
        "netEquity": "115.997795254213646297",
        "netMarginValue": "106.8772437379809635851964751341",
        "netValidMargin": "106.8749576964049635851964751341",
        "netAvailableMargin": "98.9019815577382969181964751341",
        "loanMargin": "6.666666666666666667",
        "loanMM": "1",
        "ltv": "0.158259202333793917"
    }
}
FieldTyperemark
channelStringChannel name:Accounts
dataArrayMargin call snapshot
>portfolioIdStringPortfolio ID
>exchangeTypeStringExchange this margin status applies to: BINANCE, OKX, EDX
>equityStringTotal account equity on this venue, valued in USDT-equivalent (including cash balance and P&L).
>marginValueStringTotal margin value on this venue.
>frozenMarginStringLocked margin (e.g. for open orders or positions) and unavailable for new trades or withdrawal.
>perpMarginStringMargin allocated specifically to perpetual contracts.
>debtMarginStringMargin used to cover borrowing and negative balances.
>openLossMarginStringMargin portion reserved to cover current open losses.
>validMarginStringmarginValue-openLossMargin
>availableMarginStringMargin available for opening new positions or for withdrawal.
>maintainMarginStringMinimum margin required across all positions to avoid liquidation.
>positionValueStringNotional value of all open positions on this venue.
>uniMMRStringvalidMargin/maintainMargin.
Unified maintenance margin rate, used to measure risk, a forced liquidation is triggered when the value is below 100%.
>riskRatioString1/uniMMR.
>accountStatusStringCurrent account status: NORMAL (healthy), MARGIN_CALL (approaching liquidation threshold), LIQUIDATED (liquidation in progress)
>upnlStringUnrealized profit and loss of the account in USDT.
>perpAvailableMarginStringAvailable margin for perpetual trading.
>createAtStringTimestamp when the position was first opened (milliseconds).
>updateAtStringTimestamp of this update (milliseconds).
>totalLoanValueStringTotal loan value in USDT. Pushed only if the account has any asset with loan > 0.
>netEquityStringAsset equity minus loan. Pushed only if the account has any asset with loan > 0.
>netMarginValueStringnetEquityValue × discountRate. Pushed only if the account has any asset with loan > 0.
>netValidMarginStringnetMarginValue - openLossMargin. Pushed only if the account has any asset with loan > 0.
>netAvailableMarginStringnetValidMargin - frozenMargin. Pushed only if the account has any asset with loan > 0.
>loanMarginStringΣ loan × indexPrice / loanLeverage. Pushed only if the account has any asset with loan > 0.
>loanMMStringΣ loan × indexPrice × loanMMR. Pushed only if the account has any asset with loan > 0.
>ltvStringLTV = totalLoanValue / VaildMargin, returns "0" when no loan is outstanding. Pushed only if the account has any asset with loan > 0.