Spot Account/Trade
New Order (TRADE)
Response ACK:
{
"symbol": "BTC/USDC",
"orderId": 28,
"orderListId": -1, //Unless OCO, value will be -1
"clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
"transactTime": 1507725176595
}
Response RESULT:
{
"symbol": "BTC/USDC",
"orderId": 28,
"orderListId": -1, //Unless OCO, value will be -1
"clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
"transactTime": 1507725176595,
"price": "0.00000000",
"origQty": "10.00000000",
"executedQty": "10.00000000",
"cummulativeQuoteQty": "10.00000000",
"status": "FILLED",
"timeInForce": "GTC",
"type": "MARKET",
"side": "SELL",
"strategyId": 1, // This is only visible if the field was populated on order placement.
"strategyType": 1000000 // This is only visible if the field was populated on order placement.
}
POST /api/v2/order (HMAC SHA256)
Send in a new order.
Parameters:
Name |
Type |
Mandatory |
Description |
symbol |
STRING |
YES |
|
side |
ENUM |
YES |
Used with BUY , SELL |
type |
ENUM |
YES |
Used with MARKET , LIMIT , STOP , STOP_LIMIT ,
SELECT
|
timeInForce |
ENUM |
NO |
Used with GTC , IOC , FOK , POST_ONLY |
quantity |
DECIMAL |
NO |
|
price |
DECIMAL |
NO |
|
newClientOrderId |
STRING |
NO |
A unique id among open orders. Automatically generated if not sent. |
reduceOnly |
BOOLEAN |
NO |
Used with true , false |
targetStrategy |
INT |
NO |
Used with REDUCE_ONLY=101 ,
PROFIT_LIMIT=120 ,
PROFIT_LIMIT_REDUCE_ONLY=121 ,
PROFIT_MARKET=130 ,
PROFIT_MARKET_REDUCE_ONLY=131 ,
STOP_MARKET=150< ,
STOP_MARKET_REDUCE_ONLY=151 ,
TRAILING_STOP_LIMIT=160 ,
TRAILING_STOP_LIMIT_REDUCE_ONLY=161 ,
TRAILING_STOP_MARKET=170 ,
TRAILING_STOP_MARKET_REDUCE_ONLY=171 ,
TWAP=180 ,
TWAP_REDUCE_ONLY=181
|
stopPrice |
DECIMAL |
NO |
Used with STOP_LOSS , STOP_LOSS_LIMIT , TAKE_PROFIT , and TAKE_PROFIT_LIMIT
orders.
|
recvWindow |
LONG |
NO |
The value cannot be greater than 60000 |
timestamp |
LONG |
YES |
|
expireTime |
LONG |
NO |
|
instrumentId |
LONG |
NO |
|
isHidden |
INT |
NO |
Used with true1 , false=0 |
assetId |
LONG |
NO |
Used with select assets |
tokenId |
LONG |
NO |
Used with select assets |
groupAssetId |
LONG |
NO |
Used with select assets |
selectId |
LONG |
NO |
Used with select assets |
quoteType |
ENUM |
NO |
Used with RFQ orders INDICATIVE , TRADEABLE ,
RESTRICTED_TRADEABLE , COUNTER_TRADEABLE , NONE
|
quoteTargetUserId |
LONG |
NO |
Used with select assets |
origOrdId |
LONG |
NO |
|
price2 |
DECIMAL |
NO |
|
actionType |
INT |
NO |
Used with EDIT_RFQ_ORDER=1 , RESPOND_RFQ_ORDER=2 ,
ACCEPT_RFQ_ORDER=3
|
userId |
LONG |
NO |
|
account |
LONG |
NO |
|
Additional mandatory parameters based on type
:
Type |
Additional mandatory parameters |
LIMIT |
timeInForce , quantity , price |
MARKET |
quantity or quoteOrderQty |
STOP_LOSS |
quantity , stopPrice or trailingDelta |
STOP_LOSS_LIMIT |
timeInForce , quantity , price , stopPrice or
trailingDelta
|
TAKE_PROFIT |
quantity , stopPrice or trailingDelta |
TAKE_PROFIT_LIMIT |
timeInForce , quantity , price , stopPrice or
trailingDelta
|
LIMIT_MAKER |
quantity , price |
Other info:
LIMIT_MAKER
are LIMIT
orders that will be rejected if they would immediately
match and trade as a taker.
STOP_LOSS
and TAKE_PROFIT
will execute a MARKET
order when the
stopPrice
is reached.
-
MARKET
orders using the quantity
field specifies the amount of the base
asset
the user wants to buy or sell at the market price.
- For example, sending a
MARKET
order on BTC/USDC will specify how much BTC the user
is buying or selling.
-
MARKET
orders using quoteOrderQty
specifies the amount the user wants to spend
(when buying) or receive (when selling) the quote
asset; the correct quantity
will be determined based on the market liquidity and quoteOrderQty
.
-
Using BTC/USDC as an example:
- On the
BUY
side, the order will buy as many BTC as
quoteOrderQty
USDT can.
- On the
SELL
side, the order will sell as much BTC needed to receive
quoteOrderQty
USDT.
MARKET
orders using quoteOrderQty
will not break LOT_SIZE
filter
rules; the order will execute a quantity
that will have the notional value as close as
possible to quoteOrderQty
.
- same
newClientOrderId
can be accepted only when the previous one is filled, otherwise the
order will be rejected.
- For
STOP_LOSS
, STOP_LOSS_LIMIT
, TAKE_PROFIT_LIMIT
and
TAKE_PROFIT
orders, trailingDelta
can be combined with stopPrice
.
Trigger order price rules against market price for both MARKET and LIMIT versions:
- Price above market price:
STOP_LOSS
BUY
, TAKE_PROFIT
SELL
- Price below market price:
STOP_LOSS
SELL
, TAKE_PROFIT
BUY
Data Source:
Matching Engine
Cancel Order (TRADE)
Response:
{
"symbol": "LTC/BTC",
"origClientOrderId": "myOrder1",
"orderId": 4,
"orderListId": -1, //Unless part of an OCO, the value will always be -1.
"clientOrderId": "cancelMyOrder1",
"price": "2.00000000",
"origQty": "1.00000000",
"executedQty": "0.00000000",
"cummulativeQuoteQty": "0.00000000",
"status": "CANCELED",
"timeInForce": "GTC",
"type": "LIMIT",
"side": "BUY"
}
DELETE /api/v2/order (HMAC SHA256)
Cancel an active order.
Parameters:
Name |
Type |
Mandatory |
Description |
symbol |
STRING |
YES |
|
orderId |
LONG |
NO |
|
origClientOrderId |
STRING |
NO |
|
newClientOrderId |
STRING |
NO |
Used to uniquely identify this cancel. Automatically generated by default. |
recvWindow |
LONG |
NO |
The value cannot be greater than 60000 |
timestamp |
LONG |
YES |
|
Either orderId
or origClientOrderId
must be sent.
If both orderId
and origClientOrderId
are provided, orderId
takes
precedence.
Data Source:
Matching Engine
Query Order (USER_DATA)
Response:
{
"symbol": "LTC/BTC",
"orderId": 1,
"orderListId": -1, //Unless OCO, value will be -1
"clientOrderId": "myOrder1",
"price": "0.1",
"origQty": "1.0",
"executedQty": "0.0",
"cummulativeQuoteQty": "0.0",
"status": "NEW",
"timeInForce": "GTC",
"type": "LIMIT",
"side": "BUY",
"stopPrice": "0.0",
"time": 1499827319559,
"updateTime": 1499827319559,
"isWorking": true,
"origQuoteOrderQty": "0.000000"
}
GET /api/v2/orderStatus (HMAC SHA256)
Check an order's status.
Parameters:
Name |
Type |
Mandatory |
Description |
symbol |
STRING |
YES |
|
orderId |
LONG |
NO |
|
origClientOrderId |
STRING |
NO |
|
recvWindow |
LONG |
NO |
The value cannot be greater than 60000 |
timestamp |
LONG |
YES |
|
Notes:
- Either
orderId
or origClientOrderId
must be sent.
- For some historical orders
cummulativeQuoteQty
will be < 0, meaning the data is not
available at this time.
Data Source:
Memory => Database
Cancel Replace (TRADE)
Response SUCCESS:
//Both the cancel order placement and new order placement succeeded.
{
"cancelResult": "SUCCESS",
"newOrderResult": "SUCCESS",
"cancelResponse": {
"symbol": "BTC/USDC",
"origClientOrderId": "DnLo3vTAQcjha43lAZhZ0y",
"orderId": 9,
"orderListId": -1,
"clientOrderId": "osxN3JXAtJvKvCqGeMWMVR",
"price": "0.01000000",
"origQty": "0.000100",
"executedQty": "0.00000000",
"cummulativeQuoteQty": "0.00000000",
"status": "CANCELED",
"timeInForce": "GTC",
"type": "LIMIT",
"side": "SELL"
},
"newOrderResponse": {
"symbol": "BTC/USDC",
"orderId": 10,
"orderListId": -1,
"clientOrderId": "wOceeeOzNORyLiQfw7jd8S",
"transactTime": 1652928801803,
"price": "0.02000000",
"origQty": "0.040000",
"executedQty": "0.00000000",
"cummulativeQuoteQty": "0.00000000",
"status": "NEW",
"timeInForce": "GTC",
"type": "LIMIT",
"side": "BUY",
"fills": []
}
}
Response when Cancel Order Fails with STOP_ON_FAILURE:
{
"code": -2022,
"msg": "Order cancel-replace failed.",
"data": {
"cancelResult": "FAILURE",
"newOrderResult": "NOT_ATTEMPTED",
"cancelResponse": {
"code": -2011,
"msg": "Unknown order sent."
},
"newOrderResponse": null
}
}
Response when Cancel Order Succeeds but New Order Placement Fails:
{
"code": -2021,
"msg": "Order cancel-replace partially failed.",
"data": {
"cancelResult": "SUCCESS",
"newOrderResult": "FAILURE",
"cancelResponse": {
"symbol": "BTC/USDC",
"origClientOrderId": "86M8erehfExV8z2RC8Zo8k",
"orderId": 3,
"orderListId": -1,
"clientOrderId": "G1kLo6aDv2KGNTFcjfTSFq",
"price": "0.006123",
"origQty": "10000.000000",
"executedQty": "0.000000",
"cummulativeQuoteQty": "0.000000",
"status": "CANCELED",
"timeInForce": "GTC",
"type": "LIMIT_MAKER",
"side": "SELL"
},
"newOrderResponse": {
"code": -2010,
"msg": "Order would immediately match and take."
}
}
}
Response when Cancel Order fails with ALLOW_FAILURE:
{
"code": -2021,
"msg": "Order cancel-replace partially failed.",
"data": {
"cancelResult": "FAILURE",
"newOrderResult": "SUCCESS",
"cancelResponse": {
"code": -2011,
"msg": "Unknown order sent."
},
"newOrderResponse": {
"symbol": "BTC/USDC",
"orderId": 11,
"orderListId": -1,
"clientOrderId": "pfojJMg6IMNDKuJqDxvoxN",
"transactTime": 1648540168818
}
}
}
Response when both Cancel Order and New Order Placement fail:
{
"code": -2022,
"msg": "Order cancel-replace failed.",
"data": {
"cancelResult": "FAILURE",
"newOrderResult": "FAILURE",
"cancelResponse": {
"code": -2011,
"msg": "Unknown order sent."
},
"newOrderResponse": {
"code": -2010,
"msg": "Order would immediately match and take."
}
}
}
POST /api/v2/order/cancelReplace
Cancels an existing order and places a new order on the same symbol.
Filters and Order Count are evaluated before the processing of the cancellation and order placement
occurs.
A new order that was not attempted (i.e. when newOrderResult: NOT_ATTEMPTED
), will still
increase the order count by 1.
Parameters:
Name |
Type |
Mandatory |
Description |
symbol |
STRING |
YES |
|
side |
ENUM |
YES |
|
type |
ENUM |
YES |
|
cancelReplaceMode |
ENUM |
YES |
The allowed values are: STOP_ON_FAILURE - If the cancel request fails, the new
order placement will not be attempted. ALLOW_FAILURE - new order placement will be
attempted even if cancel request fails.
|
timeInForce |
ENUM |
NO |
|
quantity |
DECIMAL |
NO |
|
quoteOrderQty |
DECIMAL |
NO |
|
price |
DECIMAL |
NO |
|
cancelNewClientOrderId |
STRING |
NO |
Used to uniquely identify this cancel. Automatically generated by default. |
cancelOrigClientOrderId |
STRING |
NO |
Either the cancelOrigClientOrderId or cancelOrderId must be provided. If
both are provided, cancelOrderId takes precedence.
|
cancelOrderId |
LONG |
NO |
Either the cancelOrigClientOrderId or cancelOrderId must be provided. If
both are provided, cancelOrderId takes precedence.
|
newClientOrderId |
STRING |
NO |
Used to identify the new order. |
strategyId |
INT |
NO |
|
strategyType |
INT |
NO |
The value cannot be less than 1000000 . |
stopPrice |
DECIMAL |
NO |
|
newOrderRespType |
ENUM |
NO |
Allowed values: ACK , RESULT , FULL
MARKET and LIMIT orders types default to FULL ; all other
orders default to ACK
|
recvWindow |
LONG |
NO |
The value cannot be greater than 60000 |
timestamp |
LONG |
YES |
|
Similar to POST /api/v2/order
, additional mandatory parameters are determined by
type
.
Response format varies depending on whether the processing of the message succeeded, partially succeeded, or
failed.
Data Source:
Matching Engine
Current Open Orders (USER_DATA)
Response:
[
{
"symbol": "LTC/BTC",
"orderId": 1,
"orderListId": -1, //Unless OCO, the value will always be -1
"clientOrderId": "myOrder1",
"price": "0.1",
"origQty": "1.0",
"executedQty": "0.0",
"cummulativeQuoteQty": "0.0",
"status": "NEW",
"timeInForce": "GTC",
"type": "LIMIT",
"side": "BUY",
"stopPrice": "0.0",
"time": 1499827319559,
"updateTime": 1499827319559,
"isWorking": true,
"origQuoteOrderQty": "0.000000"
}
]
GET /api/v2/openOrders (HMAC SHA256)
Get all open orders on a symbol. Careful when accessing this with no symbol.
Parameters:
Name |
Type |
Mandatory |
Description |
symbol |
STRING |
NO |
|
recvWindow |
LONG |
NO |
The value cannot be greater than 60000 |
timestamp |
LONG |
YES |
|
- If the symbol is not sent, orders for all symbols will be returned in an array.
Data Source:
Memory => Database
All Orders (USER_DATA)
Response:
[
{
"symbol": "LTC/BTC",
"orderId": 1,
"orderListId": -1, //Unless OCO, the value will always be -1
"clientOrderId": "myOrder1",
"price": "0.1",
"origQty": "1.0",
"executedQty": "0.0",
"cummulativeQuoteQty": "0.0",
"status": "NEW",
"timeInForce": "GTC",
"type": "LIMIT",
"side": "BUY",
"stopPrice": "0.0",
"time": 1499827319559,
"updateTime": 1499827319559,
"isWorking": true,
"origQuoteOrderQty": "0.000000"
}
]
GET /api/v2/allOrders (HMAC SHA256)
Get all account orders; active, canceled, or filled.
Parameters:
Name |
Type |
Mandatory |
Description |
symbol |
STRING |
YES |
|
orderId |
LONG |
NO |
|
startTime |
LONG |
NO |
|
endTime |
LONG |
NO |
|
limit |
INT |
NO |
Default 500; max 1000. |
recvWindow |
LONG |
NO |
The value cannot be greater than 60000 |
timestamp |
LONG |
YES |
|
Notes:
- If
orderId
is set, it will get orders >= that orderId
. Otherwise most
recent orders are returned.
- For some historical orders
cummulativeQuoteQty
will be < 0, meaning the data is not
available at this time.
- If
startTime
and/or endTime
provided, orderId
is not required.
Data Source: Database
Response:
{
"makerCommission": 15,
"takerCommission": 15,
"buyerCommission": 0,
"sellerCommission": 0,
"canTrade": true,
"canWithdraw": true,
"canDeposit": true,
"brokered": false,
"updateTime": 123456789,
"accountType": "SPOT",
"balances": [
{
"asset": "BTC",
"free": "4723846.89208129",
"locked": "0.00000000"
},
{
"asset": "LTC",
"free": "4763368.68006011",
"locked": "0.00000000"
}
],
"permissions": [
"SPOT"
]
}
GET /api/v2/account (HMAC SHA256)
Get current account information.
Parameters:
Name |
Type |
Mandatory |
Description |
recvWindow |
LONG |
NO |
The value cannot be greater than 60000 |
timestamp |
LONG |
YES |
|
Data Source: Memory => Database
Account Trade List (USER_DATA)
Response:
[
{
"symbol": "CCC/USD",
"id": 28457,
"orderId": 100234,
"orderListId": -1, //Unless OCO, the value will always be -1
"price": "4.00000100",
"qty": "12.00000000",
"quoteQty": "48.000012",
"commission": "10.10000000",
"commissionAsset": "USD",
"time": 1499865549590,
"isBuyer": true,
"isMaker": false,
"isBestMatch": true
}
]
GET /api/v2/myTrades (HMAC SHA256)
Get trades for a specific account and symbol.
Parameters:
Name |
Type |
Mandatory |
Description |
symbol |
STRING |
YES |
|
orderId |
LONG |
NO |
This can only be used in combination with symbol . |
startTime |
LONG |
NO |
|
endTime |
LONG |
NO |
|
fromId |
LONG |
NO |
TradeId to fetch from. Default gets most recent trades. |
limit |
INT |
NO |
Default 500; max 1000. |
recvWindow |
LONG |
NO |
The value cannot be greater than 60000 |
timestamp |
LONG |
YES |
|
Notes:
- If
fromId
is set, it will get id >= that fromId
.
Otherwise most recent trades are returned.
- The time between
startTime
and endTime
can't be longer than 24 hours.
Data Source:
Memory => Database
Query Current Order Count Usage (TRADE)
Response:
[
{
"rateLimitType": "ORDERS",
"interval": "SECOND",
"intervalNum": 10,
"limit": 10000,
"count": 0
},
{
"rateLimitType": "ORDERS",
"interval": "DAY",
"intervalNum": 1,
"limit": 20000,
"count": 0
}
]
GET /api/v2/rateLimit/order
Displays the user's current order count usage for all intervals.
Parameters:
Name |
Type |
Mandatory |
Description |
recvWindow |
LONG |
NO |
The value cannot be greater than 60000 |
timestamp |
LONG |
YES |
|
Data Source:
Memory