Skip to main content

Position Mode (Hedge / One-way)

Description

Query or change the position mode.

ZTDX only supports One-way Mode

Hedge mode is not supported. A POST that requests dualSidePosition=true is rejected with -4059. Existing one-way positions are unaffected; clients that read this field via GET will always see false.

HTTP Request

  • Query: GET /fapi/v1/positionSide/dual (HMAC SHA256)
  • Change: POST /fapi/v1/positionSide/dual (HMAC SHA256)

Weight

1

Request Parameters (POST only)

NameTypeRequiredDescription
dualSidePositionBOOL or STRINGYES"true" / "false" / true / false. Only false is accepted; true returns -4059.
recvWindowLONGNOSee Endpoint Security Type
timestampLONGYESTimestamp

Response Example (GET)

{
"dualSidePosition": true // true: Hedge Mode; false: One-way Mode
}

Response Example (POST)

{
"code": 200,
"msg": "success"
}

Code Examples

curl (query)

API_KEY="your_api_key"
API_SECRET="your_api_secret"
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-sepolia.ztdx.io/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.ztdx.io"

# Query position mode
timestamp = int(time.time() * 1000)
qs = f"timestamp={timestamp}"
sig = hmac.new(API_SECRET.encode(), qs.encode(), hashlib.sha256).hexdigest()
response = requests.get(
f"{BASE_URL}/fapi/v1/positionSide/dual",
params={"timestamp": timestamp, "signature": sig},
headers={"X-MBX-APIKEY": API_KEY}
)
print(response.json()) # {"dualSidePosition": false}