查詢持倉 (實時)
該接口可以獲取用戶的持倉信息,比如持倉數量,累計盈虧等
HTTP 請求
GET /unified/v3/private/position/list
請求參數
| 參數 | 是否必需 | 類型 | 說明 |
|---|---|---|---|
| category | true | string | 產品類型. linear, option |
| symbol | false | string | 合約名稱 |
| baseCoin | false | string | 交易幣種.
|
| settleCoin | false | string | 結算幣種 |
| direction | false | string | 翻頁方向. prev: 向前, next: 向後. 默認: next |
| limit | false | integer | 每頁數量限制. [1, 200]. 默認: 20 |
| cursor | false | string | 游標,用於翻頁 |
響應參數
- linear
- option
| 參數 | 類型 | 說明 |
|---|---|---|
| nextPageCursor | string | 游標,用於翻頁 |
| category | string | 產品類型 |
| list | array | Object |
| > symbol | string | 合約名稱 |
| > leverage | string | 槓桿倍數. 注意: 組合保證金模式下,該字段返回"",槓桿規則失效 |
| > updatedTime | integer | 倉位數據更新時間戳 (ms) |
| > side | string | 訂單方向. `Buy`, `Sell` |
| > positionValue | string | 倉位價值 |
| > takeProfit | string | 止盈價格 |
| > tpslMode | string | 止盈止損模式. `Partial`, `Full` |
| > riskId | integer | 風險限額ID. 注意: 組合保證金模式下,該字段返回0,風險限額規則失效 |
| > trailingStop | string | 追蹤止損 (距離當前價格的距離) |
| > entryPrice | string | 平均入場價 |
| > unrealisedPnl | string | 未結盈虧 |
| > markPrice | string | 標記價格 |
| > size | string | 倉位大小 |
| > stopLoss | string | 止損價格 |
| > cumRealisedPnl | string | 累計已結盈虧 |
| > positionMM | string | 倉位維持保證金. 組合保證金模式下,該字段返回"" |
| > createdTime | integer | 建立倉位時間戳 (毫秒) |
| > positionIdx | integer | 倉位標識, 用于在不同仓位模式下标识仓位 |
| > positionIM | string | 倉位初始保證金. 組合保證金模式下,該字段返回"" |
| 參數 | 類型 | 說明 |
|---|---|---|
| nextPageCursor | string | 游標,用於翻頁 |
| category | string | 產品類型 |
| list | array | Object |
| > symbol | string | 合約名称 |
| > updatedTime | integer | 倉位數據更新時間 (毫秒) |
| > side | string | 方向. `Buy`, `Sell` |
| > positionValue | string | 倉位價值 |
| > entryPrice | string | 平均入場價 |
| > unrealisedPnl | string | 未結盈虧 |
| > markPrice | string | 標記價格 |
| > size | string | 倉位大小 |
| > cumRealisedPnl | string | 累计已结盈亏 |
| > positionMM | string | 倉位維持保證金. 組合保證金模式下,該字段返回"" |
| > createdTime | integer | 建立倉位時間戳 (毫秒) |
| > positionIdx | integer | 期權無效, 默認為`0` |
| > positionIM | string | 倉位初始保證金. 組合保證金模式下,該字段返回"" |
請求示例
- Console-linear
- Console-option
GET /unified/v3/private/position/list?category=linear&symbol=XRPUSDT HTTP/1.1
Host: api-testnet.bybit.com
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: XXXXX
X-BAPI-TIMESTAMP: 1672820718517
X-BAPI-RECV-WINDOW: 5000
GET /unified/v3/private/position/list?category=option&baseCoin=ETH HTTP/1.1
Host: api-testnet.bybit.com
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: XXXXX
X-BAPI-TIMESTAMP: 1672018474913
X-BAPI-RECV-WINDOW: 5000
響應示例
- linear
- option
{
"retCode": 0,
"retMsg": "OK",
"result": {
"nextPageCursor": "updateAt%3D1672819200214",
"category": "linear",
"list": [
{
"symbol": "XRPUSDT",
"updatedTime": 1672819200214,
"leverage": "10",
"side": "Buy",
"positionValue": "34.91000000",
"takeProfit": "",
"tpslMode": "Partial",
"riskId": 41,
"trailingStop": "0",
"entryPrice": "0.34910000",
"unrealisedPnl": "0.00000000",
"markPrice": "0.34910000",
"size": "100.0000",
"cumRealisedPnl": "-0.02444200",
"stopLoss": "",
"positionMM": "0.36795140",
"createdTime": 1672016298024,
"positionIdx": 0,
"positionIM": "3.50985140"
}
]
},
"retExtInfo": {},
"time": 1672820720159
}
{
"retCode": 0,
"retMsg": "Success",
"result": {
"nextPageCursor": "ETH-30DEC22-700-C%3A1672018465372%2CETH-30DEC22-700-C%3A1672018465372",
"category": "option",
"list": [
{
"symbol": "ETH-30DEC22-700-C",
"updatedTime": 1672018465372,
"side": "Sell",
"positionValue": "49.80000000",
"entryPrice": "498.00000000",
"unrealisedPnl": "-2.02774092",
"markPrice": "518.27740924",
"size": "-0.1000",
"cumRealisedPnl": "0.00000000",
"positionMM": "55.72735692",
"createdTime": 1672018465365,
"positionIdx": 0,
"positionIM": "70.10719092"
}
]
},
"retExtInfo": {},
"time": 1672018475719
}