WebSocket Private Information Streams

Authentication

  • Path: /private

  • Method: WebSocket

  • Description: Websocket private channel auth on connected

  • Parameters:

├─ op: String (auth:authentication ) 
└─ args: Array
   ├─ apiKey: String  (apiKey)
   ├─ timestamp: String  (second timestamp)
   └─ signature: String
  • Response:

├─ event: String
├─ code: Number
└─ msg: String
  • Example:

Request:

{
  "op": "auth",
  "args": [
    {
      "apiKey": "985d5b66-57ce-40fb-b714-afc0b9787083",
      "timestamp": "1538054050000",
      "signature": "7L+zFQ+CEgGu5rzCj4+BdV2/uUHGqddA9pI6ztsRRPs="
    }
  ]
}

Response:

{
  "event": "auth",
  "code": 0,
  "msg": ""
}

Account Channel

  • Path: /private

  • Method: WebSocket

  • Description: Channel to subscribe account update

  • Parameters:

├─ op: String  (Operation, subscribe unsubscribe)
└─ args: Array
   ├─ channel: String  (account: account)
   └─ asset: String
  • Response:

├─ channel: String
├─ asset: String
└─ data: Object
   ├─ totalWalletBalance: String  (total wallet balance, only for USDT asset)
   ├─ totalUnrealizedProfit: String  (total unrealized profit, only for USDT asset)
   ├─ totalMarginBalance: String  (total margin balance, only for USDT asset)
   ├─ totalPositionMargin: String  (initial margin required for positions with current mark price, only for USDT asset)
   ├─ totalFrozenMargin: String  (initial margin required for open orders with current mark price, only for USDT asset)
   ├─ totalFrozenMoney: String  (total frozen money, only for USDT asset)
   ├─ totalAvailableBalance: String  (available balance, only for USDT asset)
   └─ assets: Array
      ├─ asset: String
      ├─ walletBalance: String  (wallet balance)
      ├─ unrealizedProfit: String  (unrealized profit)
      ├─ marginBalance: String  (margin balance)
      ├─ positionMargin: String  (total initial margin required with current mark price)
      ├─ frozenMargin: String  (initial margin required for open orders with current mark price)
      ├─ frozenMoney: String  (frozen money)
      ├─ availableBalance: String  (available balance)
      └─ updateTime: Number
  • Example:

Request:

{
  "op": "subscribe",
  "args": [
    {
      "channel": "account",
      "asset": "USDT"
    }
  ]
}

Response:

{
  "channel": "account",
  "asset": "USDT"
  "data": {
    "totalWalletBalance": "23.72469206",
    "totalUnrealizedProfit": "0.00000000",
    "totalMarginBalance": "23.72469206",
    "totalPositionMargin": "0.00000000",
    "totalFrozenMargin": "0.00000000",
    "totalFrozenMoney": "0.00000000",
    "totalAvailableBalance": "23.72469206",
    "assets": [
      {
        "asset": "USDT",
        "walletBalance": "23.72469206",
        "unrealizedProfit": "0.00000000",
        "marginBalance": "23.72469206",
        "positionMargin": "0.00000000",
        "frozenMargin": "0.00000000",
        "frozenMoney": "0.00000000",
        "availableBalance": "23.72469206",
        "updateTime": 1625474304765
      }
    ]
  }
}

Positions Channel

  • Path: /private

  • Method: WebSocket

  • Description: Channel to subscribe position update

  • Parameters:

├─ op: String  (Operation, subscribe unsubscribe)
└─ args: Array
   ├─ channel: String  (position: positions)
   └─ symbol: String  (only support empty string, which means to subscribe all symbols)
  • Response:

├─ channel: String
├─ symbol: String
└─ data: Array
   ├─ symbol: String
   ├─ positionSide: String
   ├─ marginType: String  (margin mode:ISOLATED/CROSSED)
   ├─ positionAmt: String  (Position quantity. The symbol represents the long and short direction. Positive numbers are many and negative numbers are empty)
   ├─ availableAmt: String  (Open position quantity)
   ├─ leverage: String
   ├─ openPrice: String
   ├─ unRealizedProfit: String  (Unrealized profits and losses of positions)
   ├─ positionMargin: String  (Position margin)
   ├─ isAutoAddMargin: String  (If increase margin when Isolated)
   ├─ isolatedMargin: String  (Isolated margin)
   ├─ markPrice: String  (Mark price)
   ├─ liquidationPrice: String  (Liquidation price)
   ├─ marginRate: String  (Margin rate)
   └─ updateTime: Number
  • Example:

Request:

{
  "op": "subscribe",
  "args": [
    {
      "channel": "position",
      "symbol": ""
    }
  ]
}

Response:

{
  "channel": "position",
  "symbol": "ETH-USDC"
  "data": [
    {
      "symbol": "ETH-USDC",
      "positionSide": "NET",
      "marginType": "CROSSED",
      "positionAmt": "-234.78",
      "availableAmt": "200",
      "leverage": "10",
      "openPrice": "0.00000",
      "unRealizedProfit": "0.00",
      "positionMargin": "0.00",
      "isAutoAddMargin": "false",
      "isolatedMargin": "0.00",
      "markPrice": "6679.50671178",
      "liquidationPrice": "0",
      "marginRate": "0",
      "updateTime": 1625474304765
    }
  ]
}

Order Channel

  • Path: /private

  • Method: WebSocket

  • Description: Channel to subscribe order status update

  • Parameters:

├─ op: String  (Operation, subscribe unsubscribe)
└─ args: Array
   ├─ channel: String  (order: orders)
   └─ symbol: String
  • Response:

├─ channel: String
├─ symbol: String
└─ data: Array
   ├─ symbol: String
   ├─ side: String
   ├─ positionSide: String
   ├─ status: String
   ├─ price: String
   ├─ origQty: String  (Original quantity)
   ├─ origType: String  (Original order type)
   ├─ type: String  (order type)
   ├─ timeInForce: String
   ├─ orderId: String  (System order number)
   ├─ clientOrderId: String  (User defined order number)
   ├─ reduceOnly: Boolean  (if reduce position only)
   ├─ workingType: String  (Conditional price trigger type)
   ├─ stopPrice: String  (please ignore when order type is TRAILING_STOP_MARKET)
   ├─ closePosition: Boolean  (if Close-All)
   ├─ activatePrice: String  (activation price, only return with TRAILING_STOP_MARKET order)
   ├─ priceRate: String  (callback rate, only return with TRAILING_STOP_MARKET order)
   ├─ priceProtect: Boolean  (if conditional order trigger is protected)
   ├─ orderTime: Number
   ├─ cumQuote: String  (trades amount)
   ├─ executedQty: String  (trades quantity)
   ├─ avgPrice: String  (trades price)
   ├─ updateTime: Number
   └─ frozenMargin: String
  • Example:

Request:

{
  "op": "subscribe",
  "args": [
    {
      "channel": "order",
      "symbol": "ETH-USDC"
    }
  ]
}

Response:

{
  "channel": "order",
  "symbol": "ETH-USDC"
  "data": [
    {
      "symbol": "ETH-USDC",
      "side": "BUY",
      "positionSide": "SHORT",
      "status": "NEW",
      "price": "0",
      "origQty": "0.40",
      "origType": "TRAILING_STOP_MARKET",
      "type": "TRAILING_STOP_MARKET",
      "timeInForce": "GTC",
      "orderId": "1573346959",
      "clientOrderId": "abc",
      "reduceOnly": false,
      "workingType": "LAST_PRICE",
      "stopPrice": "9300",
      "closePosition": false,
      "activatePrice": "9020",
      "priceRate": "0.3",
      "priceProtect": false,
      "orderTime": 1579276756075,
      "cumQuote": "0",
      "executedQty": "0",
      "avgPrice": "0.00000",
      "updateTime": 1579276756075,
      "frozenMargin": "12.34"
    }
  ]
}

Last updated