Get Position Info
Query real-time position data, such as position size, cumulative realized PNL, etc.
info
UTA2.0(inverse)
- You can query all open positions with
/v5/position/list?category=inverse; - Cannot query multiple symbols in one request
UTA1.0(inverse) & Classic (inverse)
- You can query all open positions with
/v5/position/list?category=inverse; symbolparameter can pass up to 10 symbols, e.g.,symbol=BTCUSD,ETHUSD
HTTP Request
GET /v5/position/list
Request Parameters
| Parameter | Required | Type | Comments |
|---|---|---|---|
| category | true | string | Product type |
| symbol | false | string | Symbol name, like BTCUSDT, uppercase only
|
| baseCoin | false | string | Base coin, uppercase only. option only. Return all option positions if not passed |
| settleCoin | false | string | Settle coinlinear: either symbol or settleCoin is required. symbol has a higher priority |
| limit | false | integer | Limit for data size per page. [1, 200]. Default: 20 |
| cursor | false | string | Cursor. Use the nextPageCursor token from the response to retrieve the next page of the result set |
Response Parameters
| Parameter | Type | Comments |
|---|---|---|
| category | string | Product type |
| nextPageCursor | string | Refer to the cursor request parameter |
| list | array | Object |
| > positionIdx | integer | Position idx, used to identify positions in different position modes
|
| > riskId | integer | Risk tier ID for portfolio margin mode, this field returns 0, which means risk limit rules are invalid |
| > riskLimitValue | string | Risk limit value for portfolio margin mode, this field returns 0, which means risk limit rules are invalid |
| > symbol | string | Symbol name |
| > side | string | Position side. Buy: long, Sell: short |
| > size | string | Position size, always positive |
| > avgPrice | string | Average entry price |
| > positionValue | string | Position value |
| > tradeMode | integer | Trade mode
|
| > autoAddMargin | integer | Whether to add margin automatically when using isolated margin mode 0: false1: true |
| > positionStatus | String | Position status. Normal, Liq, Adl |
| > leverage | string | Position leverage for portfolio margin mode, this field returns "", which means leverage rules are invalid |
| > markPrice | string | Mark price |
| > liqPrice | string | Position liquidation price
|
| > bustPrice | string | Bankruptcy price: Only applicable to the classic account |
| > positionIM | string | Initial margin |
| > positionIMByMp | string | Initial margin calculated by mark price |
| > positionMM | string | Maintenance margin |
| > positionMMByMp | string | Maintenance margin calculated by mark price |
| > positionBalance | string | Position margin |
| > takeProfit | string | Take profit price |
| > stopLoss | string | Stop loss price |
| > trailingStop | string | Trailing stop (The distance from market price) |
| > sessionAvgPrice | string | USDC contract session avg price, it is the same figure as avg entry price shown in the web UI |
| > delta | string | Delta |
| > gamma | string | Gamma |
| > vega | string | Vega |
| > theta | string | Theta |
| > unrealisedPnl | string | Unrealised PnL |
| > curRealisedPnl | string | The realised PnL for the current holding position |
| > cumRealisedPnl | string | Cumulative realised pnl
|
| > adlRankIndicator | integer | Auto-deleverage rank indicator. What is Auto-Deleveraging? |
| > createdTime | string | Timestamp of the first time a position was created on this symbol (ms) |
| > updatedTime | string | Position updated timestamp (ms) |
| > seq | long | Cross sequence, used to associate each fill and each position update
|
| > isReduceOnly | boolean | Useful when Bybit lower the risk limit
|
| > mmrSysUpdatedTime | string | Useful when Bybit lower the risk limit
false: the timestamp when the MMR had been adjusted by system |
| > leverageSysUpdatedTime | string | Useful when Bybit lower the risk limit
false: the timestamp when the leverage had been adjusted by system |
| > tpslMode | string | deprecated, always "Full" |
Request Example
- HTTP
- Python
- Java
- Node.js
GET /v5/position/list?category=inverse&symbol=BTCUSD HTTP/1.1
Host: api-testnet.bybit.com
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: xxxxxxxxxxxxxxxxxx
X-BAPI-TIMESTAMP: 1672280218882
X-BAPI-RECV-WINDOW: 5000
from pybit.unified_trading import HTTP
session = HTTP(
testnet=True,
api_key="xxxxxxxxxxxxxxxxxx",
api_secret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
)
print(session.get_positions(
category="inverse",
symbol="BTCUSD",
))
import com.bybit.api.client.domain.*;
import com.bybit.api.client.domain.position.*;
import com.bybit.api.client.domain.position.request.*;
import com.bybit.api.client.service.BybitApiClientFactory;
var client = BybitApiClientFactory.newInstance().newAsyncPositionRestClient();
var positionListRequest = PositionDataRequest.builder().category(CategoryType.LINEAR).symbol("BTCUSDT").build();
client.getPositionInfo(positionListRequest, System.out::println);
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'xxxxxxxxxxxxxxxxxx',
secret: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
});
client
.getPositionInfo({
category: 'inverse',
symbol: 'BTCUSD',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
Response Example
{
"retCode": 0,
"retMsg": "OK",
"result": {
"list": [
{
"positionIdx": 0,
"riskId": 1,
"riskLimitValue": "150",
"symbol": "BTCUSD",
"side": "Sell",
"size": "300",
"avgPrice": "27464.50441675",
"positionValue": "0.01092319",
"tradeMode": 0,
"positionStatus": "Normal",
"autoAddMargin": 1,
"adlRankIndicator": 2,
"leverage": "10",
"positionBalance": "0.00139186",
"markPrice": "28224.50",
"liqPrice": "",
"bustPrice": "999999.00",
"positionMM": "0.0000015",
"positionMMByMp": "0.0000015",
"positionIM": "0.00010923",
"positionIMByMp": "0.00010923",
"tpslMode": "Full",
"takeProfit": "0.00",
"stopLoss": "0.00",
"trailingStop": "0.00",
"unrealisedPnl": "-0.00029413",
"curRealisedPnl": "0.00013123",
"cumRealisedPnl": "-0.00096902",
"seq": 5723621632,
"isReduceOnly": false,
"mmrSysUpdateTime": "",
"leverageSysUpdatedTime": "",
"sessionAvgPrice": "",
"createdTime": "1676538056258",
"updatedTime": "1697673600012"
}
],
"nextPageCursor": "",
"category": "inverse"
},
"retExtInfo": {},
"time": 1697684980172
}