Switch Position Mode
Switches between one-way and hedge position modes for a coin.
| Method | POST |
| Path | /v5/position/switch-mode |
| Auth | Authenticated. |
caution
You can only change mode when you have no open positions and no open orders for the coin. The call fails otherwise.
Body parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
category | string | Yes | linear. |
coin | string | Yes | Settlement coin (e.g. USDT). The mode applies to all symbols that settle in this coin. |
mode | integer | Yes | 0 = one-way (single position per symbol). 3 = hedge (independent long and short positions). |
Modes
| Mode | Value | Behaviour |
|---|---|---|
| One-way | 0 | One net position per symbol. Buying when short reduces / flips the position. Use positionIdx: 0 on orders. |
| Hedge | 3 | Independent long and short positions on the same symbol. Use positionIdx: 1 (long) or 2 (short) on orders. |
Hedge mode is recommended for strategies that quote both sides simultaneously.
Request
- Python
- Java
- Go
- Node.js
from reference_client import sign_request, BASE_URL
import requests, json
payload = {
"category": "linear",
"coin": "USDT",
"mode": 3
}
headers, path = sign_request("POST", "/v5/position/switch-mode")
r = requests.post(BASE_URL + path, headers=headers, data=json.dumps(payload))
print(r.json())
Map<String, Object> body = new HashMap<>();
body.put("category", "linear");
body.put("coin", "USDT");
body.put("mode", 3);
HttpResponse<String> resp = client.send(
"POST", "/v5/position/switch-mode", null, body);
System.out.println(resp.body());
body := map[string]any{
"category": "linear",
"coin": "USDT",
"mode": 3,
}
bodyJSON, _ := json.Marshal(body)
headers, p, err := SignRequest("POST", "/v5/position/switch-mode", nil)
if err != nil { panic(err) }
req, _ := http.NewRequest("POST", BaseURL+p, bytes.NewReader(bodyJSON))
for k, v := range headers { req.Header.Set(k, v) }
resp, err := http.DefaultClient.Do(req)
if err != nil { panic(err) }
defer resp.Body.Close()
out, _ := io.ReadAll(resp.Body)
fmt.Println(string(out))
const {signRequest, BASE_URL} = require('./reference-client');
const body = {
"category": "linear",
"coin": "USDT",
"mode": 3
};
const {headers, path} = signRequest('POST', '/v5/position/switch-mode');
const r = await fetch(BASE_URL + path, {
method: 'POST',
headers,
body: JSON.stringify(body),
});
console.log(await r.json());
Response
{
"retCode": 0,
"retMsg": "All symbols switched successfully.",
"result": {},
"retExtInfo": {},
"time": 1756460696928
}