Get All Current Positions
API Description
This interface allows users to query all current open positions(filled orders).
Note: Current positions data is available via both Resful and Websocket APIs. This page describes the RESTful API. For information on the Websocket API, please click here
Precautions
- This interface closely resembles "closing postions at market price" endpoint. Users should carefully distinguish similar URLs and ensure the correct request method is used to avoid unintended actions.
Authentication
This is a private interface and requires authentication. For details on using the RESTful API, refer to Introduction > Authentication & Code Snippet > Futures > RESTful Private Interface.
Request Method
GET
Endpoint
Frequency Limit
The frequency limit for this interface is 30 requests/second per user ID and 100000 requests/2s per IP. In addition to this per-interface limit, a global rate limit is also enforced.
For detailed information on Global rate limits and API Rate Limiting Policy, please refer to the "Frequency Limit" section at click here
Request Parameters
This interface does not require any request parameter.
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| id | Long | Position ID |
| base | String | Contract base currency, such as BTC |
| baseSize | BigDecimal | Contract face value |
| createdDate | Long | Position creation timestamp |
| currentPiece | BigDecimal | Current number of contracts |
| closedPiece | Integer | Number of closed contracts. |
| direction | String | Trade direction:long/short |
| fee | BigDecimal | Funding fee |
| fundingSettle | BigDecimal | Settled funding fee |
| indexPrice | BigDecimal | Index price at trigger |
| instrument | String | Base currency of the instrument e.g., BTC or ETH. |
| leverage | BigDecimal | Position leverage |
| margin | BigDecimal | Margin used by position |
| orderPrice | BigDecimal | Order execution price |
| openPrice | BigDecimal | Position opening price |
| originalType | String | Original order type |
| posType | String | Position type upon order execution:plan/planTrigger/execute |
| positionMargin | BigDecimal | Position margin |
| positionModel | Integer | position Margin mode: 0: Isolated margin, 1: Cross margin. |
| quantity | String | Specifies order size based on quantityUnit: If quantityUnit=0, the quantity is measured the quote currency (e.g., USDT in BTC-USDT), If quantityUnit=1, the quantity is measured in number of contracts, If quantityUnit=2, the quantity is measured in the base currency (e.g., BTC in BTC-USDT) |
| quantityUnit | BigDecimal | Specifies the unit for order size: 0: Denominated in the quote currency (e.g., USDT in BTC-USDT), 1: Denominated in number of contracts, 2: Denominated in the base currency (e.g., BTC in BTC-USDT) |
| status | String | Status: (open/close) |
| totalPiece | BigDecimal | Total number of contracts |
| updatedDate | String | Last update timestamp |
| userId | Long | User ID |
| autoDeleveragingScore | Integer | (user can ignore it) |
| triggerType | Integer | Specifies type of order once "triggerPrice" is met: 0: Limit order. 1 : Market order |
| profitUnreal | Float | Current unrealized profit or loss of the open position |
| liquidationPrice | Float | Liquidation price |
| triggerPrice | BigDecimal | Trigger price for perpetual contract plan order |
Request Example
The following Python code shows how to get all the current open positions information.
Note: For a complete code example, please refer to General Information > Authentication and Code Snippet > Futures > RESTful Private Interface.
params = {}
api_url = "/v1/perpum/positions/all"
method = "GET"
response_code, response_data = FuturesRestfulPrivate(params, api_url, method, sec_key, api_key) # function FuturesRestfulPrivate() is defined in section (General Information > Authentication and Code Snippet > Futures > RESTful Private Interface)
Note: For a complete Java code example, please refer to General Information > Authentication and Code Snippet > Futures > RESTful Private Interface.
Response Example
The following is an example response returned by the above Python request:
{'code': 0,
'data': [{'autoDeleveragingScore': 1,
'base': 'sand',
'baseSize': 10.0,
'closedPiece': 0,
'createdDate': 1751972973000,
'currentPiece': 1,
'direction': 'long',
'fee': '0.0014',
'fundingFee': '0',
'fundingSettle': 0,
'id': 2435521222635399738,
'indexPrice': 0.24477,
'instrument': 'SAND',
'leverage': 2,
'liquidationPrice': 0.123594777082913,
'margin': 1.2223,
'openPrice': 0.24477,
'orderPrice': 2147483647,
'originalType': 'execute',
'posType': 'execute',
'positionMargin': 1.22385,
'positionModel': 0,
'positionVersion': 0,
'profitReal': 0,
'profitUnreal': 0.0001,
'quantity': 1.22385,
'quantityUnit': 1,
'source': 'web',
'status': 'open',
'totalPiece': 1,
'updatedDate': 1751972973000,
'userId': 1162061},
{'autoDeleveragingScore': 1,
'base': 'btc',
'baseSize': 0.001,
'closedPiece': 0,
'createdDate': 1751973010000,
'currentPiece': 1,
'direction': 'short',
'fee': '0.0652',
'fundingFee': '0',
'fundingSettle': 0,
'id': 2435521222635399758,
'indexPrice': 108828,
'instrument': 'BTC',
'leverage': 2,
'liquidationPrice': 162591.22485053807,
'margin': 54.3486,
'openPrice': 108827.9,
'orderPrice': 0,
'originalType': 'execute',
'posType': 'execute',
'positionMargin': 54.41395,
'positionModel': 0,
'positionVersion': 0,
'profitReal': 0,
'profitUnreal': -0.0002,
'quantity': 54.41395,
'quantityUnit': 1,
'source': 'web',
'status': 'open',
'totalPiece': 1,
'updatedDate': 1751973010000,
'userId': 1162061}],
'msg': ''}