Skip to main content

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

/v1/perpum/updateTpsl

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

ParameterMandatoryTypeDescription
idtrueLongOrder ID/Position ID/Plan ID
instrumentfalseStringThe 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.
stopProfitOrderPricefalseBigDecimalTake profit limit price
stopLossPricefalseBigDecimalStop loss price
stopProfitPricefalseBigDecimalTake profit price
stopLossRatefalseBigDecimalStop loss rate
stopProfitRatefalseBigDecimalTake profit rate
priceTypefalseIntegerTake profit and stop loss trigger price type:
1: Index price
2: Latest price
3: Mark price
stopFromtrueIntegerOrder type after take profit/stop loss is triggered:
1: Limit order
2: Market order
3: Conditional order
stopTypefalseIntegerType of stop loss/take profit:
1: Take profit/stop loss in batches
2: Entire position take profit/stop loss
closePiecefalseBigDecimalNumber of take profit/stop loss contracts (Mandatory for take profit/stop loss in batches)

Response Parameters

ParameterTypeDescription
msgStringReturns "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'}