Get SL/TP Information
API Description
This interface allows querying the stop loss (SL) and take profit (TP) information for both filled and unfilled orders in futures trading.
Note: SL/TP information is only available via RESTful API.
Precautions
None
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 10 requests/2s per user ID and 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
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| orderId | false | Long | Order ID |
| openId | false | Long | Position ID |
| planOrderId | false | Long | Plan order ID |
| stopFrom | true | Integer | Stop loss and take profit order type: 1: Requires an Order ID of the "plan" order. 2: Requires a Position ID from the "execute" market. 3: Requires a Plan Order ID from the "planTrigger" order. Note: Depending upon the order type,corresponding ID is mandatory to be specified. |
| instrument | false | String | The base currency of the instrument. (e.g., BTC or btc). This parameter is case-insensitive. Note: For instruments that start with numbers (e.g., 1000PEPE), both uppercase and lowercase formats are valid. |
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| currentPiece | BigDecimal | Number of current stop loss and take profit orders |
| closePiece | BigDecimal | Number of contracts in batch stop loss and take profit orders |
| direction | String | Trade direction: long, short |
| createdDate | Long | Order creation timestamp |
| updatedDate | Long | Timestamp of latest update |
| id | String | ID |
| indexPrice | BigDecimal | Index price at trigger |
| instrument | String | Base currency of the instrument e.g., BTC or ETH. |
| leverage | Integer | Position leverage |
| openId | Long | Position ID |
| priceType | Integer | Trigger price type for stop loss and take profit : 1: index price 2: latest price 3: mark price |
| stopLossPrice | BigDecimal | Stop loss price |
| stopLossRate | BigDecimal | Stop loss rate |
| stopProfitPrice | BigDecimal | Take profit price |
| stopProfitRate | BigDecimal | Take profit rate |
| stopLossOrderPrice | String | Stop loss limit price |
| stopProfitOrderPrice | String | Take profit limit price |
| stopProfitType | String | Perpetual contract plan order type after triggering: plan: Limit price execute: Market price |
| stopLossType | String | Perpetual contract plan order type after triggering: plan: Limit price execute: Market price |
| triggerStatus | Integer | Take profit and stop loss trigger status: 0: Not triggered, 1: Triggered, 2: Canceled |
| userId | Long | Futures account user ID |
| positionModel | Integer | Position margin mode: 0: Isolated margin 1: Cross margin |
| stopType | Integer | Stop loss and take profit order type: 1: Limit order 2: Market order3: Plan order |
| orderId | Long | Order ID |
Request Example
The following Python code shows how to get the stop loss and take profit information for a filled order.
Note: For a complete code example, please refer to Introduction > Authentication & Code Snippet > Futures > RESTful Private Interface.
params = {
"openId" : "2435521222632076385", # position ID
"stopFrom" : "2", # 2: Position
}
api_url = "/v1/perpum/TPSL"
method = "GET"
response_code, response_data = FuturesRestfulPrivate(params, api_url, method, sec_key, api_key)
print(f"Response Code: {response_code}") # function FuturesRestfulPrivate() is defined in section (Introduction > Authentication & Code Snippet > Futures > RESTful Private Interface)
Note: For a complete Java code example, please refer to Introduction > Authentication & Code Snippet > Futures > RESTful Private Interface.
Response Example
The following is an example response returned by the above Python request:
{'code': 0,
'data': [{'closePiece': 2,
'createdDate': 1740771128000,
'currentPiece': 2,
'direction': 'long',
'id': 33308288734471132,
'indexPrice': 84530.2,
'instrument': 'BTC',
'leverage': 2,
'openId': 2435521222632076385,
'positionModel': 0,
'priceType': 2,
'stopLossPrice': 82000,
'stopLossRate': 0.05404302,
'stopLossType': 'execute',
'stopProfitPrice': 95000,
'stopProfitRate': 0.2544624,
'stopProfitType': 'execute',
'stopType': 2,
'triggerStatus': 0,
'updatedDate': 1740771128000,
'userId': 1162061}],
'msg': ''}