跳到主要内容

全部撤单

描述

撤销调用方所有当前挂单或部分成交订单,可选择范围限定于单一市场。仅影响调用方自身的订单——同一市场上其他用户的挂单不受影响。

HTTP 请求

DELETE /spot/orders(JWT 或 API Key)

权重

0——订单接口不受按 IP 权重限制约束。撮合引擎内部设有 mpsc 积压队列;若队列溢出,响应为 503 ENGINE_BUSY

请求参数

名称类型必填描述
symbolSTRING可选市场 id(例如 DFUSDT)。若不传,则撤销调用方在所有市场上的当前挂单。区分大小写。

响应示例

200 OK

{
"canceled": [
{
"id": "9f2a1c4e-5b67-4d8a-bf93-2e1f4a6c8d10",
"symbol": "DFUSDT",
"side": "buy",
"type": "limit",
"tif": "gtc",
"price": "0.5000",
"quantity": "100",
"quote_quantity": null,
"filled_qty": "0",
"avg_fill_price": "0",
"status": "canceled",
"reject_reason": null,
"created_at": 1778400000,
"updated_at": 1778400300
},
{
"id": "a1b2c3d4-1234-5678-abcd-ef0123456789",
"symbol": "DFUSDT",
"side": "sell",
"type": "limit",
"tif": "gtc",
"price": "0.6000",
"quantity": "200",
"quote_quantity": null,
"filled_qty": "50",
"avg_fill_price": "0.6000",
"status": "canceled",
"reject_reason": null,
"created_at": 1778400060,
"updated_at": 1778400300
}
]
}
字段说明
canceled本次请求中被转为 canceled 状态的所有订单数组。已处于终态(filled / canceled / rejected)的订单将被静默跳过,不包含在返回结果中。
status数组中每条记录的值始终为 canceled。参见订单状态
filled_qty撤单已成交的数量;部分成交订单可能不为零。
created_at, updated_atUNIX updated_at 反映撤单时间。

注意: 若调用方无当前挂单或部分成交订单(或在指定 symbol 下无任何订单),返回空数组 {"canceled": []} 也是合法的成功响应。

错误响应

HTTPerror触发条件
503ENGINE_BUSY, ENGINE_RESTARTING, spot trading disabled暂时性错误;请使用退避策略重试。

完整列表:错误码

代码示例

cURL(JWT)

JWT="your_jwt_token"

# Cancel all open orders across all markets
curl -s -X DELETE "https://api-sepolia.p99.world/api/v1/spot/orders" \
-H "Authorization: Bearer ${JWT}"

# Cancel only DFUSDT orders
curl -s -X DELETE "https://api-sepolia.p99.world/api/v1/spot/orders?symbol=DFUSDT" \
-H "Authorization: Bearer ${JWT}"

cURL(HMAC API Key)

API_KEY="your_api_key"
API_SECRET="your_api_secret"
TIMESTAMP=$(date +%s%3N)
QUERY="symbol=DFUSDT&timestamp=${TIMESTAMP}"
SIGNATURE=$(echo -n "${QUERY}" | openssl dgst -sha256 -hmac "${API_SECRET}" | awk '{print $2}')

curl -s -X DELETE \
-H "X-MBX-APIKEY: ${API_KEY}" \
"https://api-sepolia.p99.world/api/v1/spot/orders?${QUERY}&signature=${SIGNATURE}"

Python

import time, hmac, hashlib, requests
from urllib.parse import urlencode

API_KEY = "your_api_key"
API_SECRET = "your_api_secret"
BASE_URL = "https://api-sepolia.p99.world/api/v1"

def signed_delete(path: str, params: dict = None) -> dict:
ts = int(time.time() * 1000)
qs_params = {**(params or {}), "timestamp": ts}
qs = urlencode(qs_params)
sig = hmac.new(API_SECRET.encode(), qs.encode(), hashlib.sha256).hexdigest()
r = requests.delete(
f"{BASE_URL}{path}?{qs}&signature={sig}",
headers={"X-MBX-APIKEY": API_KEY},
timeout=10,
)
r.raise_for_status()
return r.json()

# Cancel all open orders scoped to DFUSDT
result = signed_delete("/spot/orders", {"symbol": "DFUSDT"})
print(f"Canceled {len(result['canceled'])} orders")
for o in result["canceled"]:
print(f" {o['id']} {o['side']:4} {o['quantity']} @ {o['price']} filled={o['filled_qty']}")