Skip to main content

Test New Order

Description​

Test connectivity, symbol validity, order filters, and positionSide compatibility against your current position mode without executing the order or freezing margin.

HTTP Request​

POST /fapi/v1/order/test (HMAC SHA256)

Request Parameters​

Same as New Order. Validates symbol, side, type, positionSide (LONG / SHORT in Hedge Mode; BOTH in One-way Mode), quantity, price, stopPrice, and symbol filters.

Response Example​

{}

If the test passes, the response is an empty object; if the symbol is unknown or not tradeable, error -1121 is returned.

Code Examples​

cURL​

API_KEY="your_api_key"
API_SECRET="your_api_secret"
TIMESTAMP=$(date +%s%3N)
BODY='{"symbol":"BTCUSDT","side":"BUY","type":"LIMIT","timeInForce":"GTC","quantity":"0.01","price":"60000"}'
SIGNATURE=$(echo -n "timestamp=${TIMESTAMP}${BODY}" | openssl dgst -sha256 -hmac "${API_SECRET}" | awk '{print $2}')

curl -s -X POST \
-H "X-MBX-APIKEY: ${API_KEY}" \
-H "Content-Type: application/json" \
-d "${BODY}" \
"https://api.ztdxtest.xyz/fapi/v1/order/test?timestamp=${TIMESTAMP}&signature=${SIGNATURE}"

Python​

import time, hmac, hashlib, requests, json

API_KEY = "your_api_key"
API_SECRET = "your_api_secret"
BASE_URL = "https://api.ztdxtest.xyz"

def sign(msg: str) -> str:
return hmac.new(API_SECRET.encode(), msg.encode(), hashlib.sha256).hexdigest()

def signed_post(path, body={}):
ts = int(time.time() * 1000)
qs = f"timestamp={ts}"
body_str = json.dumps(body, separators=(',', ':'))
sig = sign(qs + body_str)
return requests.post(
f"{BASE_URL}{path}?timestamp={ts}&signature={sig}",
data=body_str,
headers={"X-MBX-APIKEY": API_KEY, "Content-Type": "application/json"},
)

# Test a LIMIT BUY order for BTCUSDT (not actually executed)
resp = signed_post("/fapi/v1/order/test", body={
"symbol": "BTCUSDT",
"side": "BUY",
"type": "LIMIT",
"timeInForce": "GTC",
"quantity": "0.01",
"price": "60000",
})
print(resp.json()) # {}