Skip to main content

Current Open Orders

Description

Get current open orders for a specific trading pair.

HTTP Request

GET /fapi/v1/openOrders (HMAC SHA256)

Weight

1 (single symbol) 40 (all symbols)

Request Parameters

NameTypeRequiredDescription
symbolSTRINGNOTrading pair
timestampLONGYESTimestamp

Response Example

[
{
"avgPrice": "0.00000",
"clientOrderId": "abc",
"cumQuote": "0",
"executedQty": "0",
"orderId": 1917641,
"origQty": "0.40",
"origType": "LIMIT",
"price": "3.30000",
"reduceOnly": false,
"side": "BUY",
"positionSide": "BOTH",
"status": "NEW",
"stopPrice": "0",
"closePosition": false,
"symbol": "BTCUSDT",
"time": 1579581837605, // Order creation time
"timeInForce": "GTC",
"type": "LIMIT",
"activatePrice": "9020", // Activation price, only returned for trailing stop orders
"priceRate": "0.3", // Callback rate, only returned for trailing stop orders
"updateTime": 1579581837605, // Last update time
"workingType": "CONTRACT_PRICE",
"priceProtect": false
}
]

If no symbol is sent, all open orders will be returned.

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}" | sed 's/^.* //')

curl -s -H "X-MBX-APIKEY: ${API_KEY}" \
"https://api.ztdx.io/fapi/v1/openOrders?${QUERY_STRING}&signature=${SIGNATURE}"

Response:

[
{
"orderId": "3fa42833-9508-4061-8d80-b68563dcd521",
"symbol": "BTCUSDT",
"status": "PARTIALLY_FILLED",
"clientOrderId": "3fa42833-9508-4061-8d80-b68563dcd521",
"price": "70168.520000000000000000",
"avgPrice": "70168.520000000000000000",
"origQty": "0.035620000000000000",
"executedQty": "0.000020000000000000",
"cumQuote": "1.4033704000000000000000000000",
"timeInForce": "GTC",
"type": "LIMIT",
"reduceOnly": false,
"side": "BUY",
"positionSide": "BOTH",
"stopPrice": "0",
"workingType": "CONTRACT_PRICE",
"priceProtect": false,
"origType": "LIMIT",
"updateTime": 1774330265238,
"time": 1774330265238
}
]

Python

import time
import hmac
import hashlib
import requests

API_KEY = "your_api_key"
API_SECRET = "your_api_secret"
BASE_URL = "https://api.ztdx.io"

def sign(query_string: str) -> str:
"""Generate HMAC-SHA256 signature."""
return hmac.new(
API_SECRET.encode(), query_string.encode(), hashlib.sha256
).hexdigest()

def signed_get(path: str, params: dict) -> requests.Response:
"""Send an authenticated GET request with HMAC signature."""
params["timestamp"] = int(time.time() * 1000)
query_string = "&".join(f"{k}={v}" for k, v in params.items())
params["signature"] = sign(query_string)
return requests.get(
f"{BASE_URL}{path}",
params=params,
headers={"X-MBX-APIKEY": API_KEY},
)

# Get all open orders for BTCUSDT
response = signed_get("/fapi/v1/openOrders", {"symbol": "BTCUSDT"})
orders = response.json()

print(f"Open orders: {len(orders)}")
for order in orders:
print(
f" {order['orderId'][:8]}... {order['side']} "
f"{order['origQty']}@{order['price']} "
f"status={order['status']}"
)

Output:

Open orders: 3
3fa42833... BUY 0.035620000000000000@70168.520000000000000000 status=PARTIALLY_FILLED
1692e583... SELL 0.051465555555555556@70237.730000000000000000 status=PARTIALLY_FILLED
209d76d6... SELL 0.067150000000000000@70467.413133959894326726 status=PARTIALLY_FILLED