Skip to main content

New Algo Order (Conditional)

Description

Create a Binance-compatible conditional (algo) order. Supports take-profit, stop-loss, and trailing-stop variants backed by Primit's trigger-order engine.

HTTP Request

POST /fapi/v1/algoOrder (HMAC SHA256)

Weight

0 (subject to order rate limits)

Request Parameters

NameTypeRequiredDescription
algoTypeENUMNOCONDITIONAL (only value accepted)
symbolSTRINGYESTrading pair
sideENUMYESBUY, SELL
positionSideENUMNOMust be BOTH — Primit is one-way mode
typeENUMYESSTOP, STOP_MARKET, TAKE_PROFIT, TAKE_PROFIT_MARKET, TRAILING_STOP_MARKET
timeInForceENUMNOGTC (default), GTD. Other values accepted but treated as GTC
quantityDECIMALNOBase-currency amount. Required unless closePosition=true or quoteOrderQty is sent
quoteOrderQtyDECIMALNOUSDT-denominated size, alternative to quantity. Mutually exclusive with quantity and closePosition. Converted to a base-currency quantity at the type-appropriate reference price (price for STOP / TAKE_PROFIT, triggerPrice for STOP_MARKET / TAKE_PROFIT_MARKET, activatePrice or mark for TRAILING_STOP_MARKET) and floored to lot_size. Rejected with -1013 Filter failure: LOT_SIZE if it converts below one lot.
priceDECIMALNOLimit price; required for STOP and TAKE_PROFIT
triggerPrice / stopPriceDECIMALYES (except TRAILING_STOP_MARKET)Trigger price
workingTypeENUMNOMARK_PRICE, CONTRACT_PRICE (default)
closePositionBOOL/STRINGNOtrue closes the entire position on trigger. Mutually exclusive with quantity and reduceOnly. Only valid for STOP_MARKET / TAKE_PROFIT_MARKET.
priceProtectBOOL/STRINGNOAccepted, no-op for v1
reduceOnlyBOOL/STRINGNOtrue to make the triggered order reduce-only
activatePriceDECIMALNOTrailing-stop activation price. Defaults to current mark price
callbackRateDECIMALYES for TRAILING_STOP_MARKETTrailing callback ∈ [0.1, 10] (percent)
clientAlgoIdSTRINGNOCustom client-side ID (≤ 36 chars, [A-Za-z0-9_.-])
newOrderRespTypeENUMNOACK, RESULT. Default ACK
goodTillDateLONGYES if timeInForce=GTDAuto-cancel timestamp in ms. Must be ≥ now + 600s
recvWindowLONGNOSee auth
timestampLONGYESRequest timestamp (ms)

Response Example

{
"algoId": 12345,
"clientAlgoId": "myStopLoss-001",
"algoType": "CONDITIONAL",
"orderType": "STOP_MARKET",
"symbol": "BTCUSDT",
"side": "SELL",
"positionSide": "BOTH",
"timeInForce": "GTC",
"quantity": "0.01",
"algoStatus": "NEW",
"triggerPrice": "60000",
"price": "0",
"closePosition": false,
"priceProtect": false,
"reduceOnly": true,
"activatePrice": null,
"callbackRate": null,
"workingType": "CONTRACT_PRICE",
"createTime": 1716000000000,
"updateTime": 1716000000000,
"triggerTime": 0,
"goodTillDate": 0
}

Errors

CodeCause
-1013quoteOrderQty converts below the symbol's minimum lot size
-1100Invalid numeric value (e.g. negative price, callbackRate out of range)
-1102Missing required parameter
-1106quantity / quoteOrderQty / closePosition / reduceOnly combination invalid
-1121Unknown symbol
-1130Unsupported type / side / positionSide
-2010Per-user / per-position trigger-order limit reached, or reference price unavailable
-2021Order would immediately trigger at current price