用户强平订单
接口描述
查询用户被强平的订单历史。
HTTP请求
GET /fapi/v1/forceOrders (HMAC SHA256)
请求权重
| limit | 权重 |
|---|---|
| 发送 symbol | 20 |
| 不发送 symbol | 50 |
请求参数
| 名称 | 类型 | 是否必需 | 描述 |
|---|---|---|---|
| symbol | STRING | NO | 交易对 |
| startTime | LONG | NO | 起始时间 |
| endTime | LONG | NO | 结束时间 |
| limit | INT | NO | 默认 100; 最大 1000 |
| timestamp | LONG | YES | 时间戳 |
响应示例
[
{
"symbol": "BTCUSDT",
"orderId": 2254222045,
"clientOrderId": "forceOrder1",
"price": "56000",
"origQty": "1",
"executedQty": "1",
"cumQuote": "56000",
"status": "FILLED",
"timeInForce": "GTC",
"type": "LIQUIDATION",
"side": "SELL",
"stopPrice": "0",
"time": 1623910239123
}
]
只能查询最近3个月的强平历史。 如果不发送 symbol,则会返回所有交易对的强平单。
代码示例
cURL
API_KEY="your_api_key"
API_SECRET="your_api_secret"
TIMESTAMP=$(date +%s%3N)
QUERY_STRING="symbol=BTCUSDT&limit=100×tamp=${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/forceOrders?${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"
def sign(params: str) -> str:
return hmac.new(API_SECRET.encode(), params.encode(), hashlib.sha256).hexdigest()
def signed_get(path, params={}):
params["timestamp"] = int(time.time() * 1000)
qs = "&".join(f"{k}={v}" for k, v in params.items())
params["signature"] = sign(qs)
return requests.get(f"{BASE_URL}{path}", params=params, headers={"X-MBX-APIKEY": API_KEY})
# Get user's liquidation orders for BTCUSDT
resp = signed_get("/fapi/v1/forceOrders", params={
"symbol": "BTCUSDT",
"limit": "100"
})
print(resp.json())