User Data (orders, trades, asset, positions)

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


Orders

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",
        "orderType": "DMA",
        "timeInForce":"GTC",
        "executedQty":"0",
        "executedAmount":"0",
        "executedAvgPrice":"0",
        "lastExecutedQty":"0",
        "lastExecutedPrice":"0",
        "lastExecutedAmount":"0",
        "fee":"10",
        "feeCoin":"USDT",
        "rebate":"0.1",
        "rebateCoin":"USDT",
        "orderState":"NEW",
        "updateAt":"1703213979731",
        "createAt":"1703213979731",
        "borrowAmount":"0",
        "borrowAsset":"",
        "reason":"",
        "leverage":"1",
        "positionSide":"NONE",
        "reduceOnly":false,
        "tpTriggerPrice":"",
        "tpTriggerType":"",
        "tpPrice":"",
        "slTriggerPrice":"",
        "slTriggerType":"",
        "slPrice":"",
        "action": "",
        "actionMsg": "",
        "cancelType": "",
        "amendType": ""
    }
}
FieldTypeRemark
channelStringChannel name: Orders
instIdStringSubscribed trading pair identifier, e.g. BINANCE_SPOT_BTC_USDT, BINANCE_PERP_BTC_USDT
dataObjectOrder snapshot
>portfolioIdStringPortfolio ID
>orderIdStringSystem-generated unique order ID
>clientOrderIdStringClient-defined order ID (echoed from the place_order request)
>exchangeTypeStringExchange where the order was routed: BINANCE, OKX, EDX
>businessTypeStringProduct type: SPOT, PERP, MARGIN
>symStringTrading pair identifier, e.g. BINANCE_PERP_ETH_USDT
>limitPriceStringLimit order price. Empty string for market orders.
>orderQtyStringOrder quantity. For Binance this is the base asset quantity (e.g. ETH in ETH/USDT). For OKX this is the number of contracts. Empty string when quoteOrderQty is used instead.
>quoteOrderQtyStringOrder amount in quote asset. Only used for spot market buy orders. "0" for all other order types.
>sideStringOrder direction: BUY or SELL
>exchangeOrderTypeStringOrder type sent to the exchange: LIMIT or MARKET
>orderTypeStringLTP order routing type. DMA means the order is sent directly to the exchange.
>timeInForceStringHow long the order remains active. GTC (Good Till Cancel), IOC (Immediate Or Cancel — unfilled portion is cancelled immediately), FOK (Fill Or Kill — fully filled or fully cancelled), GTX (Post-only, equivalent to GTC + maker-only)
>executedQtyStringCumulative filled quantity so far
>executedAmountStringCumulative filled amount (price × quantity) so far
>executedAvgPriceStringVolume-weighted average fill price so far. "0" if no fills yet.
>lastExecutedQtyStringQuantity filled in the most recent fill event
>lastExecutedPriceStringPrice of the most recent fill
>lastExecutedAmountStringAmount (price × quantity) of the most recent fill
>feeStringCumulative trading fee for this order. Positive = fee charged (taker). "0" when the order earned a maker rebate instead (see rebate field).
>feeCoinStringCurrency of the trading fee. Empty string if no fee was charged.
>rebateStringCumulative maker rebate received. "0" for taker orders. For OKX spot: BUY orders return quote currency, SELL orders return base currency. For Binance spot: returns quote currency. For perpetuals: returns USDT.
>rebateCoinStringCurrency of the rebate. Empty string if no rebate was received.
>orderStateStringCurrent order status: NEW (accepted, pending submission to exchange), OPEN (resting on exchange order book), PARTIALLY_FILLED (partially filled), FILLED (fully filled), CANCELLED (cancelled), REJECT (rejected by exchange), FAIL (order placement failed)
>updateAtStringTimestamp of this update (milliseconds)
>createAtStringTimestamp when the order was created (milliseconds)
>reasonStringRejection or failure reason. Empty string if none.
>borrowAmountStringAmount borrowed for this order (margin orders only). "0" if not a margin order.
>borrowAssetStringAsset borrowed (margin orders only). Empty string if none.
>leverageStringLeverage applied to this order. "1" for spot.
>positionSideStringPosition side. NONE in one-way mode. LONG or SHORT in hedge mode.
>reduceOnlyBooleantrue means this order can only reduce an existing position, not open or increase one.
>tpTriggerPriceStringTake-profit trigger price. Empty string if not set.
>tpTriggerTypeStringPrice type used to trigger take-profit: LAST_PRICE or MARK_PRICE. Empty string if not set.
>tpPriceStringTake-profit limit price. "0" means execute at market price. Empty string if not set.
>slTriggerPriceStringStop-loss trigger price. Empty string if not set.
>slTriggerTypeStringPrice type used to trigger stop-loss: LAST_PRICE or MARK_PRICE. Empty string if not set.
>slPriceStringStop-loss limit price. "0" means execute at market price. Empty string if not set.
>actionStringIn-progress action on the order. Empty string when idle. CANCEL_PENDING (cancel request submitted), CANCEL_COMPLETED (cancel confirmed by exchange), CANCEL_FAILED (cancel rejected by exchange), AMEND_PENDING (replace request submitted), AMEND_COMPLETED (replace confirmed by exchange), AMEND_FAILED (replace rejected by exchange)
>actionMsgStringAdditional message for the current action. Usually empty.
>cancelTypeStringReason the order was cancelled. Empty string if the order has not been cancelled. USER (cancelled by user), MATCH_CANCEL (cancelled by matching engine), EXPIRE (expired per timeInForce policy), REDUCE_ONLY (cancelled because it would have increased position size), LIQUIDATING (cancelled during account liquidation), SYSTEM (cancelled by system), SYM_DELIST (cancelled because the symbol was delisted)
>amendTypeStringReason for the most recent order amendment. Empty string if never amended. USER (user-initiated replace), REDUCE_ONLY (system reduced quantity to comply with reduce-only constraint)

Trades

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": "38132969466022978",
        "portfolioId": "2066376093138754",
        "orderId": "2104172237333826",
        "exchangeType": "BINANCE",
        "businessType": "PERP",
        "sym": "BINANCE_PERP_APT_USDT",
        "side": "BUY",
        "quantity": "4",
        "price": "2.24509925",
        "tradingFee": "0.00089804",
        "tradingFeeCoin": "USDT",
        "rpnl": "0",
        "clientOrderId": "2104172237333826",
        "createAt": "1763977805203",
        "execType": "MAKER"
    }
}
NameTypeDescription
channelStringChannel name: Trades
instIdStringSubscribed trading pair identifier, e.g. OKX_PERP_BTC_USDT
dataObjectFill event payload
> transactionIdStringUnique identifier for this fill record
> portfolioIdStringPortfolio ID
> orderIdStringSystem-generated order ID this fill belongs to
> exchangeTypeStringExchange where the fill occurred: BINANCE, OKX, EDX
> businessTypeStringProduct type: SPOT, PERP, MARGIN
> symStringTrading pair identifier
> sideStringFill side: BUY or SELL
> quantityStringQuantity filled in this transaction
> priceStringFill price of this transaction
> tradingFeeStringFee for this fill. Positive = fee charged (taker). Negative = maker rebate credited to the account.
> tradingFeeCoinStringCurrency of the fee or rebate.
> rpnlStringRealized PnL generated by this fill. "0" for opening trades.
> clientOrderIdStringClient-defined order ID (echoed from the original order)
> createAtStringTimestamp of this fill (milliseconds)
> execTypeStringLiquidity role: MAKER (order rested on the book) or TAKER (order matched against the book)

Assets

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"
    }]
}
FieldTypeRemark
channelStringChannel name: Assets
dataArrayList of coin balance snapshots that changed in this update
>portfolioIdStringPortfolio ID
>coinStringCoin symbol, e.g. USDT, BTC
>exchangeTypeStringExchange this balance belongs to: BINANCE, OKX
>businessTypeStringAccount type. Returns UNI for all assets in the portfolio.
>balanceStringTotal balance of this coin including frozen funds
>equityStringEquity = balance + unrealized PnL from open positions
>availableStringAmount available for placing new orders or withdrawing
>frozenStringAmount locked due to open orders or pending operations
>overdrawStringAmount overdrawn beyond the available balance
>debtStringOutstanding borrowed amount not yet repaid (margin accounts)
>marginValueStringValue of this coin counted as collateral margin (in USDT)
>virtualBorrowStringVirtual borrow used by derivatives positions (no actual loan is taken out)
>debtMarginStringMargin reserved to cover debt obligations
>perpMarginStringMargin reserved for open perpetual contract positions
>maxTransferableStringMaximum amount that can be transferred out right now
>equityValueStringEquivalent USDT value of this coin's equity
>borrowStringAmount currently borrowed
>upnlStringUnrealized profit and loss from open positions denominated in this coin
>updateAtStringTimestamp of this update (milliseconds)
>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.

Positions

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":"NONE",
        "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",
        "liqPrice":"1.1",
        "createAt":"1704179813908",
        "updateAt":"1704179813908"
    }
}
FieldTypeRemark
channelStringChannel name: Positions
dataObjectPosition snapshot
>portfolioIdStringPortfolio ID
>positionIdStringUnique identifier for this position
>symStringTrading pair identifier, e.g. BINANCE_PERP_BTC_USDT
>positionSideStringPosition side. NONE in one-way mode. LONG or SHORT in hedge mode.
>positionMarginStringMargin currently allocated to this position
>positionMMStringMaintenance margin required to keep this position open. If actual margin falls below this value, liquidation is triggered.
>positionQtyStringNumber of contracts/units held. Positive = long, negative = short.
>positionValueStringCurrent market value of the position (mark price × quantity)
>entryValueStringValue at which the position was originally opened (entry price × quantity)
>unrealizedPNLStringUnrealized profit or loss based on the current mark price
>unrealizedPNLRateStringUnrealized PnL as a proportion of entry value
>avgPriceStringVolume-weighted average entry price of this position
>markPriceStringCurrent mark price used for PnL calculation and liquidation checks
>leverageStringLeverage currently applied to this position
>maxLeverageStringMaximum leverage allowed for this symbol
>riskLevelStringRisk tier (1–5). Higher values indicate stricter margin requirements and higher liquidation risk.
>feeStringCumulative net trading fee for this position. Positive = net fee paid. Negative = net rebate received (e.g. all fills were maker orders).
>fundingFeeStringCumulative funding fees paid (negative) or received (positive) for this position
>liqPriceStringEstimated liquidation price. null if there is no liquidation risk or the calculated price is outside a reasonable range.
>createAtStringTimestamp when the position was first opened (milliseconds)
>updateAtStringTimestamp of this update (milliseconds)

MarginCall

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
dataObjectMargin call snapshot
>portfolioIdStringPortfolio ID
>exchangeTypeStringExchange this margin status applies to: BINANCE, OKX
>marginStringCurrent total margin balance of the account
>maintainMarginStringMinimum margin required across all positions to avoid liquidation
>uniMMRStringUnified Margin Ratio = (margin − maintainMargin) / maintainMargin. A negative value means the account is already under-margined and liquidation is in progress.
>accountStatusStringCurrent account status: NORMAL (healthy), MARGIN_CALL (approaching liquidation threshold), LIQUIDATED (liquidation in progress)
>updateAtStringTimestamp of this update (milliseconds)