Position Mode (Hedge / One-way)
Description
Query or switch the account's futures position mode between Hedge Mode (dual-side: simultaneous independent LONG and SHORT positions on the same symbol) and One-way Mode (single net BOTH position per symbol).
Default Mode: Hedge Mode (Dual-Side)
All exchange users default to Hedge Mode (dualSidePosition: true). You can switch freely between Hedge Mode and One-way Mode at any time, provided you have no open positions and no active or trigger orders across all contracts. Calling POST with the mode you are already in is idempotent and succeeds immediately.
HTTP Request
Binance-Compatible FAPI (HMAC SHA256)
- Query:
GET /fapi/v1/positionSide/dual - Change:
POST /fapi/v1/positionSide/dual
Website / Wallet API (Bearer JWT or API Key)
- Query:
GET /api/v1/account/position-mode - Change:
POST /api/v1/account/position-mode
Request Parameters (POST /fapi/v1/positionSide/dual)
| Name | Type | Required | Description |
|---|---|---|---|
| dualSidePosition | BOOL or STRING | YES | true / "true" / "1" for Hedge Mode (dual-side); false / "false" / "0" for One-way Mode. Accepted in JSON body or query string. |
| recvWindow | LONG | NO | Ignored — the server enforces a fixed ±60 second timestamp window regardless of this value. |
| timestamp | LONG | YES | Timestamp in milliseconds |
Request Parameters (POST /api/v1/account/position-mode)
| Name | Type | Required | Description |
|---|---|---|---|
| dual_side_position | BOOL | NO* | true for Hedge Mode, false for One-way Mode (alias: dualSidePosition). |
| position_mode | STRING | NO* | "hedge" or "one_way" (alias: positionMode). |
* At least one of dual_side_position or position_mode must be provided.
Order Behavior by Position Mode
| Position Mode | side | positionSide | Action | Reduce-Only Behavior |
|---|---|---|---|---|
Hedge (true, default) | BUY | LONG | Open / Increase Long | Opening leg (never nets existing Short); reduceOnly=true is rejected. |
Hedge (true, default) | SELL | SHORT | Open / Increase Short | Opening leg (never nets existing Long); reduceOnly=true is rejected. |
Hedge (true, default) | SELL | LONG | Close / Reduce Long | Strictly reduce-only; never opens a Short position. |
Hedge (true, default) | BUY | SHORT | Close / Reduce Short | Strictly reduce-only; never opens a Long position. |
One-way (false) | BUY / SELL | BOTH (or omitted) | Net / Reverse | Nets opposing position first unless reduceOnly=true. |
- Sending
positionSide=BOTHwhile in Hedge Mode, orpositionSide=LONG/SHORTwhile in One-way Mode, is rejected (-4061). - In Hedge Mode, if
positionSideis omitted, the server infers it from(side, reduceOnly):(BUY, false) → LONG,(SELL, false) → SHORT,(SELL, true) → LONG,(BUY, true) → SHORT.
Error Codes
| Code | Website Code | Description |
|---|---|---|
-4068 | POSITION_MODE_LOCKED_POSITIONS | Position mode cannot be changed while open positions exist on any symbol. |
-4067 | POSITION_MODE_LOCKED_ORDERS | Position mode cannot be changed while open orders or active trigger orders exist on any symbol. |
-4061 | INVALID_ORDER | Order's positionSide does not match the account's current position mode. |
Response Example (GET)
// GET /fapi/v1/positionSide/dual
{
"dualSidePosition": true
}
// GET /api/v1/account/position-mode
{
"success": true,
"data": {
"dual_side_position": true,
"position_mode": "hedge"
},
"error": null
}
Response Example (POST)
// POST /fapi/v1/positionSide/dual
{
"code": 200,
"msg": "success"
}
Code Examples
curl (Query & Switch via FAPI)
API_KEY="your_api_key"
API_SECRET="your_api_secret"
# 1. Query current position mode (default: true = Hedge Mode)
TIMESTAMP=$(date +%s%3N)
QUERY_STRING="timestamp=${TIMESTAMP}"
SIGNATURE=$(echo -n "${QUERY_STRING}" | openssl dgst -sha256 -hmac "${API_SECRET}" | awk '{print $2}')
curl -s -H "X-MBX-APIKEY: ${API_KEY}" \
"https://api.ztdxtest.xyz/fapi/v1/positionSide/dual?${QUERY_STRING}&signature=${SIGNATURE}"
# 2. Switch to One-way Mode (requires no open positions or open orders)
TIMESTAMP=$(date +%s%3N)
QUERY_STRING="timestamp=${TIMESTAMP}"
SIGNATURE=$(echo -n "${QUERY_STRING}" | openssl dgst -sha256 -hmac "${API_SECRET}" | awk '{print $2}')
curl -s -X POST \
-H "X-MBX-APIKEY: ${API_KEY}" \
-H "Content-Type: application/json" \
-d '{"dualSidePosition": false}' \
"https://api.ztdxtest.xyz/fapi/v1/positionSide/dual?${QUERY_STRING}&signature=${SIGNATURE}"
Python
import time, hmac, hashlib, requests
API_KEY = "your_api_key"
API_SECRET = "your_api_secret"
BASE_URL = "https://api.ztdxtest.xyz"
def sign(qs: str) -> str:
return hmac.new(API_SECRET.encode(), qs.encode(), hashlib.sha256).hexdigest()
# Query position mode (default: True = Hedge Mode)
ts = int(time.time() * 1000)
qs = f"timestamp={ts}"
resp = requests.get(
f"{BASE_URL}/fapi/v1/positionSide/dual",
params={"timestamp": ts, "signature": sign(qs)},
headers={"X-MBX-APIKEY": API_KEY},
)
print(resp.json()) # {"dualSidePosition": True}
# Switch to One-way Mode (or back to Hedge Mode with True)
ts = int(time.time() * 1000)
qs = f"timestamp={ts}"
resp = requests.post(
f"{BASE_URL}/fapi/v1/positionSide/dual",
params={"timestamp": ts, "signature": sign(qs)},
json={"dualSidePosition": False},
headers={"X-MBX-APIKEY": API_KEY},
)
print(resp.json()) # {"code": 200, "msg": "success"}