跳到主要內容

用戶倉位訂閱

提示
  • 此功能使用前需要呼叫server.sign方法進行簽章鑑權
  • 此介面推送延遲為:即時推送

用戶倉位訂閱

  • 方法: position.subscribe
  • 參數:
參數名是否必須類型說明
market_listtrue[]string市場列表,空白列表代表訂閱所有市場
  • 範例:
// 訂閱單一市場
{
"method": "position.subscribe",
"params": {"market_list": ["BTCUSDT"]},
"id": 1
}

// 訂閱多個市場
{
"method": "position.subscribe",
"params": {"market_list": ["BTCUSDT", "ETHUSDT"]},
"id": 1
}

// 訂閱所有市場
{
"method": "position.subscribe",
"params": {"market_list": []},
"id": 1
}

倉位更新推送

  • 方法: position.update
  • 參數:
參數名類型說明
eventstring倉位更新事件類型
positionobject倉位資訊
position.position_idint倉位ID
position.marketstring市場名
position.sidestring倉位方向,long 或short
position.margin_modestring倉位類型,cross 或isolated
position.open_intereststring持倉數量
position.close_avblstring可平倉數量
position.ath_position_amountstring史上最大倉位數量
position.unrealized_pnlstring未實現盈虧
position.realized_pnlstring已實現盈虧
position.avg_entry_pricestring平均開倉價格
position.cml_position_valuestring累計倉位價值
position.max_position_valuestring最大倉位價值
position.take_profit_pricestring止盈價格
position.stop_loss_pricestring停損價格
position.take_profit_typestring止盈觸發價格類型,latest_price 或mark_price
position.stop_loss_typestring停損觸發價格類型,latest_price 或mark_price
position.leveragestring槓桿倍數
position.margin_avblstring可用保證金
position.ath_margin_sizestring史上最大保證金數量
position.position_margin_ratestring倉位保證金率
position.maintenance_margin_ratestring維持保證金率
position.maintenance_margin_valuestring維持保證金數量
position.liq_pricestring強平價格
position.bkr_pricestring破產價格
position.adl_levelint自動減倉等級
position.settle_pricestring結算價格,以標記價格計算
position.settle_valuestring結算價值,以標記價格計算
position.first_filled_pricestring部位第一筆成交價
position.latest_filled_pricestring部位最新一筆成交價
position.created_atint倉位創建時間戳(毫秒)
position.updated_atint倉位更新時間戳(毫秒)
  • 範例:
{
"method": "position.update",
"data": {
"event": "",
"position": {
"position_id": 246830219,
"market": "BTCUSDT",
"side": "long",
"margin_mode": "cross",
"open_interest": "0.0010",
"close_avbl": "0.0010",
"ath_position_amount": "0.0010",
"unrealized_pnl": "0.00",
"realized_pnl": "-0.01413182100000000000",
"avg_entry_price": "30721.35000000000000000000",
"cml_position_value": "30.72135000000000000000",
"max_position_value": "30.72135000000000000000",
"take_profit_price": "0.00000000000000000000",
"stop_loss_price": "0.00000000000000000000",
"take_profit_type": "latest_price",
"stop_loss_type": "latest_price",
"leverage": "50",
"margin_avbl": "0.61442700000000000000",
"ath_margin_size": "0.61442700000000000000",
"position_margin_rate": "0.02000000000000000000",
"maintenance_margin_value": "0.15364710000000000000",
"maintenance_margin_rate": "0.005",
"liq_price": "31179.87761194029850746268",
"bkr_price": "31335.77700000000000000000",
"adl_level": 5,
"settle_price": "30721.35000000000000000000",
"settle_val": "30.72135000000000000000",
"first_filled_price": "30721.35",
"latest_filled_price": "30721.35",
"created_at": 1642145331234,
"updated_at": 1642145331234
}
},
"id": null
}

取消用戶倉位訂閱

  • 方法: position.unsubscribe
  • 參數:
參數名是否必須類型說明
market_listtrue[]string市場列表,空白列表代表訂閱所有市場
  • 範例:
// 取消單一市集訂閱
{
"method": "position.unsubscribe",
"params": {"market_list": ["BTCUSDT"]},
"id": 1
}

// 取消多市場訂閱
{
"method": "position.unsubscribe",
"params": {"market_list": ["BTCUSDT", "ETHUSDT"]},
"id": 1
}

// 取消所有市集的訂閱
{
"method": "position.unsubscribe",
"params": {"market_list": []},
"id": 1
}