Skip to main content

Close Batch Positions

API Description

This interface allows users to close multiple positions in a batch at market price by specifying thirdOrderId (a custom ID defined by users when placing orders).

Note: Close Batch Positions is only available via RESTful API.

Precautions

  1. Typically, a position is closed by placing an identical order in the opposite direction. However, this approach does not apply on CoinW. Placing an order in the opposite direction will open a new position instead of closing the original one, resulting in two active positions. To properly close a position, please use this dedicated interface.
  2. This interface requires "thirdOrderId" to close batch positions. If multiple positions share the same "thirdOrderId", all corresponding positions will be closed.
  3. This interface only supports batch position closing at market price and does not allow users to specify a closing price. To close a position at a specific price, please refer to the interface in Futures > Place orders > Close a Position.
  4. During the funding period, operations related to transaction such as placing orders or closing positions are not permitted. Attempting these actions will result in an error response. The funding process typically takes 30 to 40 seconds. It is recommended to wait at least 1 minute before retrying transaction related operations. For the exact funding fee schedule, please refer to the official webpage.
  5. 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/batchClose

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
thirdOrderIdtrueStringCustom Order ID

Response Parameters

ParameterTypeDescription
openIdLongOrder ID
thirdOrderIdLongCustom Order ID

Request Example

The following Python code shows how to close batch positions.

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

params1 = { "thirdOrderId" : "111111111111", }
params2 = { "thirdOrderId" : "2222222222",}
params = [params1,params2]

api_url = "/v1/perpum/batchClose"
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,
'data': [
{'msgCode': 0,'openId': '33308750244767807','thirdOrderId': '111111111111'},
{'msgCode': 0, 'openId': '33308750244776514', 'thirdOrderId': '2222222222'}
],'msg': ''}