Trading requests
Place new order (TRADE)
{
"id": "56374a46-3061-486b-a311-99ee972eb648",
"method": "order.place",
"params": {
"symbol": "BTCUSDT",
"side": "SELL",
"type": "LIMIT",
"timeInForce": "GTC",
"price": "23416.10000000",
"quantity": "0.00847000",
"apiKey": "vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A",
"signature": "15af09e41c36f3cc61378c2fbe2c33719a03dd5eba8d0f9206fbda44de717c88",
"timestamp": 1660801715431
}
}
Send in a new order.
This adds 1 order to the EXCHANGE_MAX_ORDERS filter and the MAX_NUM_ORDERS filter.
Weight: 1
Unfilled Order Count: 1
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
symbol | STRING | YES | |
side | ENUM | YES | BUY or SELL |
type | ENUM | YES | |
timeInForce | ENUM | NO * | |
price | DECIMAL | NO * | |
quantity | DECIMAL | NO * | |
quoteOrderQty | DECIMAL | NO * | |
newClientOrderId | STRING | NO | Arbitrary unique ID among open orders. Automatically generated if not sent |
newOrderRespType | ENUM | NO | Select response format:
|
stopPrice | DECIMAL | NO * | |
trailingDelta | INT | NO * | See Trailing Stop order FAQ |
icebergQty | DECIMAL | NO | |
strategyId | LONG | NO | Arbitrary numeric value identifying the order within an order strategy. |
strategyType | INT | NO | Arbitrary numeric value identifying the order strategy. Values smaller than |
selfTradePreventionMode | ENUM | NO | The allowed enums is dependent on what is configured on the symbol. Supported values: STP Modes |
pegPriceType | ENUM | NO | PRIMARY_PEG or MARKET_PEG See Pegged Orders |
pegOffsetValue | INT | NO | Price level to peg the price to (max: 100) See Pegged Orders |
pegOffsetType | ENUM | NO | Only PRICE_LEVEL is supported See Pegged Orders |
apiKey | STRING | YES | |
recvWindow | DECIMAL | NO | The value cannot be greater than 60000. Supports up to three decimal places of precision (e.g., 6000.346) so that microseconds may be specified. |
signature | STRING | YES | |
timestamp | LONG | YES |
Certain parameters (*) become mandatory based on the order type:
Order type |
Mandatory parameters |
|---|---|
LIMIT |
|
LIMIT_MAKER |
|
MARKET |
|
STOP_LOSS |
|
STOP_LOSS_LIMIT |
|
TAKE_PROFIT |
|
TAKE_PROFIT_LIMIT |
|
Supported order types:
Order type |
Description |
|---|---|
LIMIT |
Buy or sell |
LIMIT_MAKER |
This order type is also known as a POST-ONLY order. |
MARKET |
Buy or sell at the best available market price.
|
STOP_LOSS |
Execute a
I.e., when |
STOP_LOSS_LIMIT |
Place a |
TAKE_PROFIT |
Like |
TAKE_PROFIT_LIMIT |
Like |
Notes on using parameters for Pegged Orders:
- These parameters are allowed for
LIMIT,LIMIT_MAKER,STOP_LOSS_LIMIT,TAKE_PROFIT_LIMITorders. - If
pegPriceTypeis specified,pricebecomes optional. Otherwise, it is still mandatory. pegPriceType=PRIMARY_PEGmeans the primary peg, that is the best price on the same side of the order book as your order.pegPriceType=MARKET_PEGmeans the market peg, that is the best price on the opposite side of the order book from your order.- Use
pegOffsetTypeandpegOffsetValueto request a price level other than the best one. These parameters must be specified together.
Available timeInForce options,
setting how long the order should be active before expiration:
| TIF | Description |
|---|---|
GTC | Good 'til Canceled – the order will remain on the book until you cancel it, or the order is completely filled. |
IOC | Immediate or Cancel – the order will be filled for as much as possible, the unfilled quantity immediately expires. |
FOK | Fill or Kill – the order will expire unless it cannot be immediately filled for the entire quantity. |
Notes:
-
newClientOrderIdspecifiesclientOrderIdvalue for the order.A new order with the same
clientOrderIdis accepted only when the previous one is filled or expired. -
Any
LIMITorLIMIT_MAKERorder can be made into an iceberg order by specifying theicebergQty.An order with an
icebergQtymust havetimeInForceset toGTC. -
Trigger order price rules for
STOP_LOSS/TAKE_PROFITorders:stopPricemust be above market price:STOP_LOSS BUY,TAKE_PROFIT SELLstopPricemust be below market price:STOP_LOSS SELL,TAKE_PROFIT BUY
-
MARKETorders usingquoteOrderQtyfollowLOT_SIZEfilter rules.The order will execute a quantity that has notional value as close as possible to requested
quoteOrderQty.
Data Source: Matching Engine
Response:
Response format is selected by using the newOrderRespType parameter.
ACK response type:
{
"id": "56374a46-3061-486b-a311-99ee972eb648",
"status": 200,
"result": {
"symbol": "BTCUSDT",
"orderId": 12569099453,
"orderListId": -1, // always -1 for singular orders
"clientOrderId": "4d96324ff9d44481926157ec08158a40",
"transactTime": 1660801715639
},
"rateLimits": [
{
"rateLimitType": "ORDERS",
"interval": "SECOND",
"intervalNum": 10,
"limit": 50,
"count": 1
},
{
"rateLimitType": "ORDERS",
"interval": "DAY",
"intervalNum": 1,
"limit": 160000,
"count": 1
},
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 6000,
"count": 1
}
]
}
RESULT response type:
{
"id": "56374a46-3061-486b-a311-99ee972eb648",
"status": 200,
"result": {
"symbol": "BTCUSDT",
"orderId": 12569099453,
"orderListId": -1, // always -1 for singular orders
"clientOrderId": "4d96324ff9d44481926157ec08158a40",
"transactTime": 1660801715639,
"price": "23416.10000000",
"origQty": "0.00847000",
"executedQty": "0.00000000",
"origQuoteOrderQty": "0.000000",
"cummulativeQuoteQty": "0.00000000",
"status": "NEW",
"timeInForce": "GTC",
"type": "LIMIT",
"side": "SELL",
"workingTime": 1660801715639,
"selfTradePreventionMode": "NONE"
},
"rateLimits": [
{
"rateLimitType": "ORDERS",
"interval": "SECOND",
"intervalNum": 10,
"limit": 50,
"count": 1
},
{
"rateLimitType": "ORDERS",
"interval": "DAY",
"intervalNum": 1,
"limit": 160000,
"count": 1
},
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 6000,
"count": 1
}
]
}
FULL response type:
{
"id": "56374a46-3061-486b-a311-99ee972eb648",
"status": 200,
"result": {
"symbol": "BTCUSDT",
"orderId": 12569099453,
"orderListId": -1,
"clientOrderId": "4d96324ff9d44481926157ec08158a40",
"transactTime": 1660801715793,
"price": "23416.10000000",
"origQty": "0.00847000",
"executedQty": "0.00847000",
"origQuoteOrderQty": "0.000000",
"cummulativeQuoteQty": "198.33521500",
"status": "FILLED",
"timeInForce": "GTC",
"type": "LIMIT",
"side": "SELL",
"workingTime": 1660801715793,
// FULL response is identical to RESULT response, with the same optional fields
// based on the order type and parameters. FULL response additionally includes
// the list of trades which immediately filled the order.
"fills": [
{
"price": "23416.10000000",
"qty": "0.00635000",
"commission": "0.000000",
"commissionAsset": "BNB",
"tradeId": 1650422481
},
{
"price": "23416.50000000",
"qty": "0.00212000",
"commission": "0.000000",
"commissionAsset": "BNB",
"tradeId": 1650422482
}
]
},
"rateLimits": [
{
"rateLimitType": "ORDERS",
"interval": "SECOND",
"intervalNum": 10,
"limit": 50,
"count": 1
},
{
"rateLimitType": "ORDERS",
"interval": "DAY",
"intervalNum": 1,
"limit": 160000,
"count": 1
},
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 6000,
"count": 1
}
]
}
Conditional fields in Order Responses
There are fields in the order responses (e.g. order placement, order query, order cancellation) that appear only if certain conditions are met.
These fields can apply to Order lists.
The fields are listed below:
| Field | Description | Visibility conditions | Examples |
|---|---|---|---|
icebergQty | Quantity for the iceberg order | Appears only if the parameter icebergQty was sent in the request. | "icebergQty": "0.00000000" |
preventedMatchId | When used in combination with symbol, can be used to query a prevented match. | Appears only if the order expired due to STP. | "preventedMatchId": 0 |
preventedQuantity | Order quantity that expired due to STP | Appears only if the order expired due to STP. | "preventedQuantity": "1.200000" |
stopPrice | Price when the algorithmic order will be triggered | Appears for STOP_LOSS. TAKE_PROFIT, STOP_LOSS_LIMIT and TAKE_PROFIT_LIMIT orders. | "stopPrice": "23500.00000000" |
strategyId | Can be used to label an order that's part of an order strategy. | Appears if the parameter was populated in the request. | "strategyId": 37463720 |
strategyType | Can be used to label an order that is using an order strategy. | Appears if the parameter was populated in the request. | "strategyType": 1000000 |
trailingDelta | Delta price change required before order activation | Appears for Trailing Stop Orders. | "trailingDelta": 10 |
trailingTime | Time when the trailing order is now active and tracking price changes | Appears only for Trailing Stop Orders. | "trailingTime": -1 |
usedSor | Field that determines whether order used SOR | Appears when placing orders using SOR | "usedSor": true |
workingFloor | Field that determines whether the order is being filled by the SOR or by the order book the order was submitted to. | Appears when placing orders using SOR | "workingFloor": "SOR" |
pegPriceType | Price peg type | Only for pegged orders | "pegPriceType": "PRIMARY_PEG" |
pegOffsetType | Price peg offset type | Only for pegged orders, if requested | "pegOffsetType": "PRICE_LEVEL" |
pegOffsetValue | Price peg offset value | Only for pegged orders, if requested | "pegOffsetValue": 5 |
peggedPrice | Current price order is pegged at | Only for pegged orders, once determined | "peggedPrice": "87523.83710000" |
expiryReason | Cause of the order’s expiration | When an order has expired | “expiryReason”: “INSUFFICIENT_LIQUIDITY” |
Test new order (TRADE)
{
"id": "6ffebe91-01d9-43ac-be99-57cf062e0e30",
"method": "order.test",
"params": {
"symbol": "BTCUSDT",
"side": "SELL",
"type": "LIMIT",
"timeInForce": "GTC",
"price": "23416.10000000",
"quantity": "0.00847000",
"apiKey": "vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A",
"signature": "15af09e41c36f3cc61378c2fbe2c33719a03dd5eba8d0f9206fbda44de717c88",
"timestamp": 1660801715431
}
}
Test order placement.
Validates new order parameters and verifies your signature but does not send the order into the matching engine.
Weight:
| Condition | Request Weight |
|---|---|
Without computeCommissionRates | 1 |
With computeCommissionRates | 20 |
Parameters:
In addition to all parameters accepted by order.place,
the following optional parameters are also accepted:
| Name | Type | Mandatory | Description |
|---|---|---|---|
computeCommissionRates | BOOLEAN | NO | Default: false See Commissions FAQ to learn more. |
Data Source: Memory
Response:
Without computeCommissionRates:
{
"id": "6ffebe91-01d9-43ac-be99-57cf062e0e30",
"status": 200,
"result": {},
"rateLimits": [
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 6000,
"count": 1
}
]
}
With computeCommissionRates:
{
"id": "6ffebe91-01d9-43ac-be99-57cf062e0e30",
"status": 200,
"result": {
"standardCommissionForOrder": { // Standard commission rates on trades from the order.
"maker": "0.00000112",
"taker": "0.00000114"
},
"specialCommissionForOrder": { // Special commission rates on trades from the order.
"maker": "0.05000000",
"taker": "0.06000000"
},
"taxCommissionForOrder": { // Tax commission rates for trades from the order
"maker": "0.00000112",
"taker": "0.00000114"
},
"discount": { // Discount on standard commissions when paying in BNB.
"enabledForAccount": true,
"enabledForSymbol": true,
"discountAsset": "BNB",
"discount": "0.25000000" // Standard commission is reduced by this rate when paying in BNB.
}
},
"rateLimits": [
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 6000,
"count": 20
}
]
}
Cancel order (TRADE)
{
"id": "5633b6a2-90a9-4192-83e7-925c90b6a2fd",
"method": "order.cancel",
"params": {
"symbol": "BTCUSDT",
"origClientOrderId": "4d96324ff9d44481926157",
"apiKey": "vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A",
"signature": "33d5b721f278ae17a52f004a82a6f68a70c68e7dd6776ed0be77a455ab855282",
"timestamp": 1660801715830
}
}
Cancel an active order.
Weight: 1
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
symbol |
STRING | YES | |
orderId |
LONG | YES | Cancel order by orderId |
origClientOrderId |
STRING | Cancel order by clientOrderId |
|
newClientOrderId |
STRING | NO | New ID for the canceled order. Automatically generated if not sent |
cancelRestrictions |
ENUM | NO | Supported values: ONLY_NEW - Cancel will succeed if the order status is NEW.ONLY_PARTIALLY_FILLED - Cancel will succeed if order status is PARTIALLY_FILLED. |
apiKey |
STRING | YES | |
recvWindow |
DECIMAL | NO | The value cannot be greater than 60000. Supports up to three decimal places of precision (e.g., 6000.346) so that microseconds may be specified. |
signature |
STRING | YES | |
timestamp |
LONG | YES |
Notes:
-
If both
orderIdandorigClientOrderIdparameters are provided, theorderIdis searched first, then theorigClientOrderIdfrom that result is checked against that order. If both conditions are not met the request will be rejected. -
newClientOrderIdwill replaceclientOrderIdof the canceled order, freeing it up for new orders. -
If you cancel an order that is a part of an order list, the entire order list is canceled.
-
The performance for canceling an order (single cancel or as part of a cancel-replace) is always better when only
orderIdis sent. SendingorigClientOrderIdor bothorderId+origClientOrderIdwill be slower.
Data Source: Matching Engine
Response:
When an individual order is canceled:
{
"id": "5633b6a2-90a9-4192-83e7-925c90b6a2fd",
"status": 200,
"result": {
"symbol": "BTCUSDT",
"origClientOrderId": "4d96324ff9d44481926157", // clientOrderId that was canceled
"orderId": 12569099453,
"orderListId": -1, // set only for legs of an order list
"clientOrderId": "91fe37ce9e69c90d6358c0", // newClientOrderId from request
"transactTime": 1684804350068,
"price": "23416.10000000",
"origQty": "0.00847000",
"executedQty": "0.00001000",
"origQuoteOrderQty": "0.000000",
"cummulativeQuoteQty": "0.23416100",
"status": "CANCELED",
"timeInForce": "GTC",
"type": "LIMIT",
"side": "SELL",
"stopPrice": "0.00000000", // present only if stopPrice set for the order
"trailingDelta": 0, // present only if trailingDelta set for the order
"icebergQty": "0.00000000", // present only if icebergQty set for the order
"strategyId": 37463720, // present only if strategyId set for the order
"strategyType": 1000000, // present only if strategyType set for the order
"selfTradePreventionMode": "NONE"
},
"rateLimits": [
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 6000,
"count": 1
}
]
}
When an order list is canceled:
{
"id": "16eaf097-bbec-44b9-96ff-e97e6e875870",
"status": 200,
"result": {
"orderListId": 19431,
"contingencyType": "OCO",
"listStatusType": "ALL_DONE",
"listOrderStatus": "ALL_DONE",
"listClientOrderId": "iuVNVJYYrByz6C4yGOPPK0",
"transactionTime": 1660803702431,
"symbol": "BTCUSDT",
"orders": [
{
"symbol": "BTCUSDT",
"orderId": 12569099453,
"clientOrderId": "bX5wROblo6YeDwa9iTLeyY"
},
{
"symbol": "BTCUSDT",
"orderId": 12569099454,
"clientOrderId": "Tnu2IP0J5Y4mxw3IATBfmW"
}
],
// order list order's status format is the same as for individual orders.
"orderReports": [
{
"symbol": "BTCUSDT",
"origClientOrderId": "bX5wROblo6YeDwa9iTLeyY",
"orderId": 12569099453,
"orderListId": 19431,
"clientOrderId": "OFFXQtxVFZ6Nbcg4PgE2DA",
"transactTime": 1684804350068,
"price": "23450.50000000",
"origQty": "0.00850000",
"executedQty": "0.00000000",
"origQuoteOrderQty": "0.000000",
"cummulativeQuoteQty": "0.00000000",
"status": "CANCELED",
"timeInForce": "GTC",
"type": "STOP_LOSS_LIMIT",
"side": "BUY",
"stopPrice": "23430.00000000",
"selfTradePreventionMode": "NONE"
},
{
"symbol": "BTCUSDT",
"origClientOrderId": "Tnu2IP0J5Y4mxw3IATBfmW",
"orderId": 12569099454,
"orderListId": 19431,
"clientOrderId": "OFFXQtxVFZ6Nbcg4PgE2DA",
"transactTime": 1684804350068,
"price": "23400.00000000",
"origQty": "0.00850000",
"executedQty": "0.00000000",
"origQuoteOrderQty": "0.000000",
"cummulativeQuoteQty": "0.00000000",
"status": "CANCELED",
"timeInForce": "GTC",
"type": "LIMIT_MAKER",
"side": "BUY",
"selfTradePreventionMode": "NONE"
}
]
},
"rateLimits": [
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 6000,
"count": 1
}
]
}
Note: The payload above does not show all fields that can appear. Please refer to Conditional fields in Order Responses.
Regarding cancelRestrictions
- If the
cancelRestrictionsvalue is not any of the supported values, the error will be:
{
"code": -1145,
"msg": "Invalid cancelRestrictions"
}
- If the order did not pass the conditions for
cancelRestrictions, the error will be:
{
"code": -2011,
"msg": "Order was not canceled due to cancel restrictions."
}