Skip to main content

Set Margin Mode

API Description

This interface allows users to configure their position margin mode to either isolated or cross margin and set position layout by choosing between merged positions (merging new positions in the same direction) or split positions (keeping new positions separate).

Note: Set margin mode is only available via RESTful API.

Precautions

  1. To change the position margin mode from Isolated to Cross or vice versa, users must ensure there are no open orders. Otherwise, the interface will return the following error:

    {'code': 9042, 'msg': 'You have an open order in this mode, please close or cancel it first.'}
  2. To change the position layout from merged to split positions or vice versa, users must ensure there are no open orders. Otherwise, the interface will also return the above error.

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/positions/type

Frequency Limit

The frequency limit for this interface is 2 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
positionModeltrueIntegerPosition margin mode:
0: Isolated margin
1: Cross margin
layouttrueStringPosition layout:
0: Merged positions (positions in same direction will be merged)
1: Split positions (positions in same direction will remain separate)

Response Parameters

ParameterTypeDescription
dataStringTRANSACTION_SUCCESS

Request Example

The following Python code shows how to set the position layout to combined (layout=0) and position margin mode to isolated (positionModel=0).

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

params = {
"layout": "0",
"positionModel": 0,
}

api_url = "/v1/perpum/positions/type"
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, 'data': 'TRANSACTION_SUCCESS', 'msg': ''}