跳到主要内容

持仓模式 (双向/单向)

接口描述

查询或更改持仓模式。

ZTDX 仅支持单向持仓模式

不支持 Hedge Mode。POST 请求 dualSidePosition=true 会被拒绝, 返回 -4059。已有的单向持仓不 受影响;客户端通过 GET 读取该字段始终拿到 false

HTTP请求

  • 查询: GET /fapi/v1/positionSide/dual (HMAC SHA256)
  • 更改: POST /fapi/v1/positionSide/dual (HMAC SHA256)

请求权重

1

请求参数 (仅限 POST)

名称类型是否必需描述
dualSidePositionBOOL 或 STRINGYES"true" / "false" / true / false。仅 false 被接受;true 返回 -4059
recvWindowLONGNO详见 接口鉴权
timestampLONGYES时间戳

响应示例 (GET)

{
"dualSidePosition": true // true: 双向持仓模式; 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-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}