New Order
Description
Create and submit a new order.
HTTP Request
POST /fapi/v1/order (HMAC SHA256)
Request Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| symbol | STRING | YES | Trading pair |
| side | ENUM | YES | Order side: BUY, SELL |
| positionSide | ENUM | NO | Accepted but not validated — whatever value is sent, the order is always processed in one-way (BOTH) mode. The value is echoed back in the response for trigger orders. |
| type | ENUM | YES | Order type: LIMIT, MARKET, STOP, TAKE_PROFIT, STOP_MARKET, TAKE_PROFIT_MARKET. STOP_LIMIT and TAKE_PROFIT_LIMIT are accepted as aliases for STOP and TAKE_PROFIT. TRAILING_STOP_MARKET is not supported here and is rejected with -1130 — use POST /fapi/v1/algoOrder for trailing stops. |
| reduceOnly | BOOL or STRING | NO | true / false / "true" / "false". Reduce-only orders are clamped to the opposite-side position size at admission and rejected with -2022 if there is no opposite-side position to reduce. reduceOnly=true orders bypass the MIN_NOTIONAL filter so a sub-10 USD residual position can still be closed; LOT_SIZE and MAX_NOTIONAL still apply. |
| quantity | DECIMAL | YES | Order quantity. Floored to the symbol's lot size; the resulting notional must satisfy the symbol's min/max bounds, otherwise -1013. The error message starts with Filter failure: <FILTER>. where <FILTER> is one of LOT_SIZE, MIN_NOTIONAL, or MAX_NOTIONAL — clients can switch on the filter type. |
| price | DECIMAL | NO | Order price (required for LIMIT-type orders) |
| newClientOrderId | STRING | NO | User-defined order ID, [A-Za-z0-9_.-], length 1–36. Persisted; round-tripped on query-order / all-orders. A duplicate ID among the caller's active orders is rejected with -2014. |
| stopPrice | DECIMAL | NO | Stop / trigger price. Required for STOP / STOP_MARKET / TAKE_PROFIT / TAKE_PROFIT_MARKET (-1102 if missing). Trigger orders whose condition is already satisfied at submission are rejected with -2021. |
| timeInForce | ENUM | NO | Time in force: GTC, IOC, FOK, GTX. GTX is post-only — a crossing GTX order is rejected with -2010. IOC / FOK semantics are strictly enforced at the engine level. |
| workingType | ENUM | NO | Accepted but ignored — trigger conditions are always evaluated against the mark price, regardless of the value sent. The value is echoed back in the response for trigger orders. |
| recvWindow | LONG | NO | Accepted but ignored — the server enforces a fixed ±60 second timestamp window instead. |
| timestamp | LONG | YES | Timestamp |
Attaching take-profit / stop-loss to a market entry
To open a position with TP and/or SL, place the market entry first, then submit one or two reduce-only trigger orders sitting on the opposite side at the desired trigger price:
| Order | type | side | stopPrice | reduceOnly |
|---|---|---|---|---|
| Entry | MARKET | your direction (BUY / SELL) | — | false |
| Take-profit | TAKE_PROFIT_MARKET | opposite of entry | TP trigger price | true |
| Stop-loss | STOP_MARKET | opposite of entry | SL trigger price | true |
The trigger orders execute as MARKET when their stopPrice is hit
against the mark price (workingType is ignored — see above).
Cancel them explicitly via DELETE /fapi/v1/order if you close the
position by other means — they are not chained to the entry.
Response Example
{
"orderId": "3fa42833-9508-4061-8d80-b68563dcd521",
"symbol": "BTCUSDT",
"status": "NEW",
"clientOrderId": "testOrder1",
"price": "60000",
"avgPrice": "0",
"origQty": "0.01",
"executedQty": "0",
"cumQuote": "0",
"timeInForce": "GTC",
"type": "LIMIT",
"reduceOnly": false,
"side": "BUY",
"positionSide": "BOTH",
"stopPrice": "0",
"workingType": "CONTRACT_PRICE",
"priceProtect": false,
"origType": "LIMIT",
"updateTime": 1774330265238,
"time": 1774330265238
}
Errors
| Code | Cause |
|---|---|
| -1013 | Filter failure: LOT_SIZE / MIN_NOTIONAL / MAX_NOTIONAL |
| -1100 | Invalid numeric value (quantity / price / stopPrice not positive or unparsable) |
| -1102 | Missing required parameter (quantity; stopPrice for trigger types; price for GTX) |
| -1121 | Unknown or non-tradeable symbol |
| -1130 | Invalid side or type (including TRAILING_STOP_MARKET) |
| -2010 | GTX post-only order would have matched immediately, or per-side OI cap exceeded |
| -2014 | Duplicate newClientOrderId — another active order already uses this ID |
| -2019 | Margin is insufficient |
| -2021 | Trigger order would immediately trigger at the current mark price |
| -2022 | ReduceOnly order rejected: no opposite-side position to reduce |
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.prex.world/fapi/v1/order?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.prex.world"
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"},
)
# Place a LIMIT BUY order for BTCUSDT
resp = signed_post("/fapi/v1/order", body={
"symbol": "BTCUSDT",
"side": "BUY",
"type": "LIMIT",
"timeInForce": "GTC",
"quantity": "0.01",
"price": "60000",
})
print(resp.json())