跳到主要内容

用户仓位订阅

提示
  • 该功能使用之前需要调用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
}