持仓模式 (双向/单向)
接口描述
查询或更改持仓模式。
ZTDX 仅支持单向持仓模式
不支持 Hedge Mode。POST 请求 dualSidePosition=true 会被拒绝,
返回 -4059。已有的单向持仓不
受影响;客户端通过 GET 读取该字段始终拿到 false。
HTTP请求
- 查询: GET
/fapi/v1/positionSide/dual(HMAC SHA256) - 更改: POST
/fapi/v1/positionSide/dual(HMAC SHA256)
请求参数 (仅限 POST)
| 名称 | 类型 | 是否必需 | 描述 |
|---|---|---|---|
| dualSidePosition | BOOL 或 STRING | NO | 省略时默认为 false。接受 true / false(布尔)或 "true" / "false" / "1" / "0" / ""(字符串;"1" 表示 true,"0" 和 "" 表示 false)。仅 false 被接受;true 返回 -4059。 |
| recvWindow | LONG | NO | 会被忽略 — 无论传何值,服务端都强制固定 ±60 秒时间戳窗口。 |
| timestamp | LONG | YES | 时间戳 |
响应示例 (GET)
{
"dualSidePosition": false // 始终为 false: 单向持仓模式
}
响应示例 (POST)
{
"code": 200,
"msg": "success"
}
代码示例
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.prex.world/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.prex.world"
# 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}