Subscribe Margin Mode
API Description
This Websocket provides real-time updates on the margin mode (Isolated or Cross Margin) and the position layout (Merged or Split Positions), allowing users to manage their trading strategy effectively.
Note: Margin mode data is accessible via both RESTful and Websocket APIs. This page describes the WebSocket API. For information on the RESTful API, please click here
Precautions
- The Websocket does not return data unless there is a change in margin mode or position layout after the connection is established. If no changes occur, no updates will be sent.
Authentication
This is a private Websocket and requires authentication. For details on using the Websocket API, please refer to Introduction > Authentication & Code Snippet > Futures > Websocket Private Interface.
Websocket URL
Frequency limit
The frequency limit for this subscription is 3 requests/s per IP.
Subscription Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| event | true | String | Subscribe or unsubscribe. sub: subscribe; unsub: unsubscribe. Note: This parameter is case-sensitive. |
| params | true | Json | Data object containing the following: |
| -biz | true | String | Specifies the channel, e.g., "futures". |
| -type | true | String | Defines the function type, e.g., "user_setting". |
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| biz | String | Specifies the channel, e.g., "futures". |
| type | String | Defines the function type, e.g., "user_setting". |
| result | boolean | Indicates whether the subscription or unsubscription was successful: true, false. |
| channel | String | Specifies the action performed: subscribe or unsubscribe. |
| -layout | Integer | Position layout: 0: Merged positions 1: Split positions |
| -positionModel | Integer | Position margin mode: 0: Isolated margin 1: Cross margin |
| -userId | Long | Contract account user ID |
Subscription Example
The following Python code shows how to check the position layout and position margin mode.
Note: For a complete code example, please refer to Introduction > Authentication & Code Snippet > Futures > Websocket Private Interface.
url = "wss://ws.futurescw.com/perpum"
subscription_payload = {"event": "sub",
"params": {"biz": "futures",
"type": "user_setting"}}
api_key= "your_api_key"
sec_key = "your_sec_key"
FuturesWebsocketPrivate(url, api_key, sec_key, subscription_payload) # function FuturesWebsocketPrivate() is defined in section (Introduction > Authentication & Code Snippet > Futures > Websocket Private Interface)
Note: For a complete Java code example, please refer to Introduction > Authentication & Code Snippet > Futures > Websocket Private Interface.
Response Example
The following is an example response returned by the above Python subscription, it keeps updatating in real-time:
{'biz': 'futures',
'data': {'result': True},
'channel': 'subscribe',
'type': 'user_setting'}
{'biz': 'futures',
'data': [{'layout': 1, 'positionModel': 1, 'userId': 600001359}],
'type': 'user_setting'}.....