Skip to main content

Cancel All Open Orders

Description

Cancel all active orders for a specific trading pair.

HTTP Request

DELETE /fapi/v1/allOpenOrders (HMAC SHA256)

Weight

1

Request Parameters

NameTypeRequiredDescription
symbolSTRINGYESTrading pair
timestampLONGYESTimestamp

Response Example

{
"code": 200,
"msg": "The operation of cancel all open orders is done."
}

This operation cancels every open order for the specified trading pair — including resting limit orders, conditional trigger_orders (TP / SL / stop / trailing-stop), and any TP/SL trigger orders attached to the caller's open positions on that symbol. Frozen margin attributable to the cancelled orders is released to available_balance in the same transaction.

Code Examples

cURL

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

curl -s -X DELETE \
-H "X-MBX-APIKEY: ${API_KEY}" \
"https://api-sepolia.ztdx.io/fapi/v1/allOpenOrders?${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_delete(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.delete(f"{BASE_URL}{path}", params=params, headers={"X-MBX-APIKEY": API_KEY})

# Cancel all open orders for BTCUSDT
resp = signed_delete("/fapi/v1/allOpenOrders", params={
"symbol": "BTCUSDT"
})
print(resp.json())