Skip to main content

Close Positions at Market Price

API Description

This interface allows users to close all positions of a specified instrument at market price.

Note: Close Positions at Market Price is only available via RESTful API.

Precautions

  1. All positions under the specified instrument will be closed at market price.
  2. This interface is similar to the "Get Current Position Information" and "Get Current Position" interfaces in terms of URL structure. Users should carefully distinguish them to ensure that the correct request method is used to avoid unexpected operations or data anomalies due to confusion.
  3. While the platform displays positions from user's own orders, copy trading, and strategy square uniformly, the OpenAPI only supports operations (such as closing positions or canceling orders) for user's own orders. For positions generated by copy trading and strategy square, API operations are not permitted, and users should use the platform's corresponding functions.

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

DELETE

Endpoint

/v1/perpum/allpositions

Frequency limit

The frequency limit for this interface is 5 requests/s 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
instrumenttrueStringThe 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

This interface does not return response parameters; receiving "code:0" implies "Success".

Request Example

The following Python code shows how to close all positions at market price.

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

params = {"instrument": "btc",}

api_url = "/v1/perpum/allpositions"

method = "DELETE"
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': ''}