全部倉位變化

Topic: /contract/positionAll

倉位操作引起的倉位變化
  //倉位操作引起的倉位變化
  
  //逐倉
  {
      "topic": "/contract/positionAll",
      "type": "message",
      "data": {
          "symbol": "XBTUSDM",
          "maintMarginReq": 0.025,
          "riskLimit": 4,
          "realLeverage": 15.163955758,
          "crossMode": false,
          "delevPercentage": 1,
          "openingTimestamp": 1717582301254,
          "autoDeposit": false,
          "currentTimestamp": 1717724618516,
          "currentQty": 2,
          "currentCost": -0.0000287732,
          "currentComm": 0.0000012641,
          "unrealisedCost": -0.0000285718,
          "realisedCost": 0.0000010627,
          "isOpen": true,
          "markPrice": 71509.37,
          "markValue": -0.0000279684,
          "posCost": -0.0000285718,
          "posCross": 0.0000000067,
          "posInit": 0.000001461,
          "posComm": 0.0000000338,
          "posLoss": 0.0000002267,
          "posMargin": 0.0000012748,
          "posFunding": -0.0000002067,
          "posMaint": 0.0000008911,
          "maintMargin": 0.0000018782,
          "avgEntryPrice": 69999.0900118298,
          "liquidationPrice": 69071.5062768731,
          "bankruptPrice": 67085.2788064187,
          "settleCurrency": "XBT",
          "changeReason": "positionChange",
          "riskLimitLevel": 1,
          "realisedGrossCost": -0.0000002014,
          "realisedGrossPnl": 0.0000002014,
          "realisedPnl": 0.0000013973,
          "unrealisedPnl": 0.0000006034,
          "unrealisedPnlPcnt": 0.0211,
          "unrealisedRoePcnt": 0.413,
          "leverage": 15.163955758, // 新增字段(同realLeverage
          "marginMode": "ISOLATED", // 新增字段
          "positionSide": "BOTH" // 新增字段
      },
      "subject": "position.change",
      "userId": "665ec530aa70390001d22576",
      "channelType": "private"
  }
  
  //全倉
  {
      "topic": "/contract/positionAll",
      "type": "message",
      "data": {
          "symbol": "XBTUSDTM",
          "crossMode": true,
          "delevPercentage": 0.06,
          "openingTimestamp": 1717639498983,
          "currentTimestamp": 1717724686618,
          "currentQty": -2,
          "currentCost": -136.002,
          "currentComm": 0.06739824,
          "unrealisedCost": -136.002,
          "realisedCost": 0.06739824,
          "isOpen": true,
          "markPrice": 70778.04,
          "markValue": -141.55608,
          "posCost": -136.002,
          "posInit": 5.4509819612,
          "posMargin": 5.6735903779,
          "avgEntryPrice": 68001,
          "liquidationPrice": 80700.49720065,
          "bankruptPrice": 81152.42267235,
          "settleCurrency": "USDT",
          "changeReason": "positionChange",
          "realisedGrossCost": 0,
          "realisedGrossPnl": 0,
          "realisedPnl": -0.09580416,
          "unrealisedPnl": -5.55408,
          "unrealisedPnlPcnt": -0.0408,
          "unrealisedRoePcnt": -1.0189,
          "leverage": 24.95, // 合约维度的全局杠杆
          "marginMode": "CROSS", // CROSS-全仓,ISOLATED-逐仓
          "positionSide": "BOTH" // 单向持仓模式为BOTH
      },
      "subject": "position.change",
      "userId": "665ec530aa70390001d22576",
      "channelType": "private"
  }
  • changeReason說明
    • “marginChange”: 倉位保證金變化;
    • “positionChange”: 倉位變化;
    • “liquidation”: 強平;
    • “autoAppendMarginStatusChange”: 修改是否自動追加保證金;
    • “adl”: 自動減倉;
標記價格變化引起的倉位變化
 //標記價格變化引起的倉位變化
  { 
    "userId": "5cd3f1a7b7ebc19ae9558591",  // 不推薦使用, 後續版本將刪除
    "topic": "/contract/positionAll", 
    "subject": "position.change", 
      "data": {
          "markPrice": 7947.83,                   //標記價格
          "markValue": 0.00251640,                 //標記價值
          "maintMargin": 0.00252044,              //倉位保證金
          "realLeverage": 10.06,                   //槓桿倍數
          "unrealisedPnl": -0.00014735,           //未實現盈虧
          "unrealisedRoePcnt": -0.0553,           //投資回報率
          "unrealisedPnlPcnt": -0.0553,            //倉位盈虧率
          "delevPercentage": 0.52,             //ADL分位數
          "currentTimestamp": 1558087175068,       //當前時間戳
          "settleCurrency": "XBT"                  //結算幣種
      }
  }
資金費用結算
 //資金費用結算
  { 
    "userId": "xbc453tg732eba53a88ggyt8c",  // 不推薦使用, 後續版本將刪除
    "topic": "/contract/positionAll",
    "subject": "position.settlement",
    "data": {
        "fundingTime": 1551770400000,          //費用時間
        "qty": 100,                            //倉位數
        "markPrice": 3610.85,                 //結算價格,爲8時刻標記價格,四捨五入到最近合法價格
        "fundingRate": -0.002966,             //結算資金費率
        "fundingFee": -296,                   //資金費用
        "ts": 1547697294838004923,             //當前時間(納秒)
        "settleCurrency": "XBT"                //結算幣種
    }
  }
風險限額調整結果
// Adjustment Result of Risk Limit Level
{ 
  "userId": "xbc453tg732eba53a88ggyt8c", 
  "topic": "/contract/positionAll", 
  "subject": "position.adjustRiskLimit", 
  "data": { 
    "success": true, // 是否成功 
    "riskLimitLevel": 1, // 當前風險限額等級
    "msg": "" // 失敗原因 
  }
} 
  • msg失敗原因有兩種情況:
    • 持倉價值大於風險限額等級額度;
    • 餘額不足,保證金追加失敗。