Skip to main content

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)​

NameTypeRequiredDescription
dualSidePositionBOOL or STRINGYEStrue / "true" / "1" for Hedge Mode (dual-side); false / "false" / "0" for One-way Mode. Accepted in JSON body or query string.
recvWindowLONGNOIgnored — the server enforces a fixed ±60 second timestamp window regardless of this value.
timestampLONGYESTimestamp in milliseconds

Request Parameters (POST /api/v1/account/position-mode)​

NameTypeRequiredDescription
dual_side_positionBOOLNO*true for Hedge Mode, false for One-way Mode (alias: dualSidePosition).
position_modeSTRINGNO*"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 ModesidepositionSideActionReduce-Only Behavior
Hedge (true, default)BUYLONGOpen / Increase LongOpening leg (never nets existing Short); reduceOnly=true is rejected.
Hedge (true, default)SELLSHORTOpen / Increase ShortOpening leg (never nets existing Long); reduceOnly=true is rejected.
Hedge (true, default)SELLLONGClose / Reduce LongStrictly reduce-only; never opens a Short position.
Hedge (true, default)BUYSHORTClose / Reduce ShortStrictly reduce-only; never opens a Long position.
One-way (false)BUY / SELLBOTH (or omitted)Net / ReverseNets opposing position first unless reduceOnly=true.
  • Sending positionSide=BOTH while in Hedge Mode, or positionSide=LONG/SHORT while in One-way Mode, is rejected (-4061).
  • In Hedge Mode, if positionSide is omitted, the server infers it from (side, reduceOnly): (BUY, false) → LONG, (SELL, false) → SHORT, (SELL, true) → LONG, (BUY, true) → SHORT.

Error Codes​

CodeWebsite CodeDescription
-4068POSITION_MODE_LOCKED_POSITIONSPosition mode cannot be changed while open positions exist on any symbol.
-4067POSITION_MODE_LOCKED_ORDERSPosition mode cannot be changed while open orders or active trigger orders exist on any symbol.
-4061INVALID_ORDEROrder'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"}