Skip to main content

Set Trailing SL/TP

API Description​

This interface allows users to configure a trailing stop loss (SL) and take profit (TP) mechanism based on a specified callback rate, applicable only to filled orders. To set up trailing SL/TP, users must provide a valid Position ID.

Note: Set trailing SL/TP is only available via RESTful API.

Precautions​

  1. This interface only supports filled orders. To set up trailing SL/TP, users must provide a position ID.
  2. The request parameter "quantity" always represents the number of contracts, even when "quantityUnit" is set to USDT denomination.

Authentication​

This is a private interface and requires authentication. For details on using the RESTful API, refer to Common > Authentication & Code Snippet > Futures > RESTful Private Interface.

Request Method​

POST

Endpoint​

/v1/perpum/moveTPSL

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
openIdtrueLongPosition ID
callbackRatetrueBigDecimalCallback rate, with a valid range from 0 to 1. For example: 0.5 represents a 50% callback rate.
triggerPricefalseBigDecimalActivation price
quantitytrueBigDecimalNumber of contracts/USDT
quantityUnitfalseIntegerSpecifies the quantity unit:
0: Denominated in USDT,
1: Denominated in contracts
Note: By default, this parameter is set to 1 (denominated in contracts).

Response Parameters​

ParameterTypeDescription
codeIntegerReturn status code (0 means success)
tsLongTimestamp (ms)

Request Example​

The following Python code shows how to set up trailing SL/TP on a filled order.

Note: For a complete code example, please refer to Common > Authentication & Code Snippet > Futures > RESTful Private Interface.

params = {
"openId": "2435521222632076385",
"callbackRate": "0.5",
"quantity": 1,
"quantityUnit": 1
}

api_url = "/v1/perpum/moveTPSL"
method = "POST"
response_code, response_data = FuturesRestfulPrivate(params, api_url, method, sec_key, api_key) # function FuturesRestfulPrivate() is defined in section (Common > Authentication & Code Snippet > Futures > Restful Private Interface)

Note: For a complete Java code example, please refer to Common > Authentication & Code Snippet > Futures > RESTful Private Interface.

Response Example​

The following is an example response returned by the above Python request:

{'code': 0, 'ts': 1775443378356, 'msg': ''}