Modify SL/TP in Batches
API Description
This interface allows users to modify stop loss (SL) and take profit (TP) orders in batches for futures trading.
Note: Modify SL/TP in Batches 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
POST
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 |
|---|---|---|---|
| id | true | Long | Order ID/Position ID/Plan ID |
| 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. |
| stopProfitOrderPrice | false | BigDecimal | Take profit limit price |
| stopLossPrice | false | BigDecimal | Stop loss price |
| stopProfitPrice | false | BigDecimal | Take profit price |
| stopLossRate | false | BigDecimal | Stop loss rate |
| stopProfitRate | false | BigDecimal | Take profit rate |
| priceType | false | Integer | Take profit and stop loss trigger price type: 1: Index price 2: Latest price 3: Mark price |
| stopFrom | true | Integer | Order type after take profit/stop loss is triggered: 1: Limit order 2: Market order 3: Conditional order |
| stopType | false | Integer | Type of stop loss/take profit: 1: Take profit/stop loss in batches 2: Entire position take profit/stop loss |
| closePiece | false | BigDecimal | Number of take profit/stop loss contracts (Mandatory for take profit/stop loss in batches) |
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| msg | String | Returns "Success" upon successful execution. |
Request Example
The following Python code shows how to modify a SL/TP order.
Note: For a complete code example, please refer to Introduction > Authentication & Code Snippet > Futures > RESTful Private Interface.
params = {
"id": 2435521222632243158,
"instrument": "btc",
"stopLossPrice": 86000 ,
"stopProfitPrice": 90000,
"priceType" : 3,
"stopFrom" : 2,
"stopType" : 1,
"closePiece" : 3,
}
api_url = "/v1/perpum/TPSL"
method = "POST"
response_code, response_data = FuturesRestfulPrivate(params, api_url, method, sec_key, api_key) # 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, 'msg': 'Success'}