Skip to main content

Trade requests

use webScoket to create or cancel orders.Parameters same as REST API

Request ParameterData TypeRequiredDescription
idStringfalserequest id,if responds, this id is returned max, length 50
eventStringtruetrade events, enumerated value eg: createOrder cancelOrders ...
paramsJsontrueevent params
Example:

Request:

# Example request
{
"id": "1234567",
"event": "createOrder",
"params": {

}
}

Response:

// Successful to return results
{
"id": "1234567",
"data": [{
"orderId": 205343650954092544,
"clientOrderId": "",
"message": "",
"code": 200
}]
}

// Failure to return results
{
"id": "123457",
"data": [{
"orderId": 0,
"clientOrderId": null,
"message": "Currency trade disabled",
"code": 21352
}]
}
{
"event": "error",
"message": "Platform in maintenance mode"
}

Create Order

params same as Create Order by call POST /orders

Create an order for an account.

Request ParameterData TypeRequiredDescription
symbolStringtrueThe symbol to trade, like BTC_USDT
sideStringtrueBUY, SELL
timeInForceStringfalseGTC, IOC, FOK (Default: GTC)
typeStringfalseMARKET, LIMIT, LIMIT_MAKER (for placing post only orders). Default type is MARKET.
accountTypeStringfalseSPOT is the default and only supported one.
priceStringfalsePrice is required for non-market orders
quantityStringfalseBase units for the order. Quantity is required for MARKET SELL or any LIMIT orders
amountStringfalseQuote units for the order. Amount is required for MARKET BUY order
clientOrderIdStringfalseMaximum 64-character length.*
allowBorrowBooleanfalseallow order to be placed by borrowing funds (Default: false)
stpModeStringfalseself-trade prevention. Defaults to EXPIRE_TAKER. None: enable self-trade; EXPIRE_TAKER: Taker order will be canceled when self-trade happens
slippageToleranceStringfalseUsed to control the maximum slippage ratio, the value range is greater than 0 and less than 1
Response FieldData TypeDescription
idStringorder id
clientOrderIdStringclientOrderId user specifies in request or an empty string.
messageStringmessage
codeint200 is ok,other is error.
Example:

Request:

{
"id": "123456789",
"event": "createOrder",
"params": {
"symbol": "BTC_USDT",
"type": "LIMIT",
"quantity": "100",
"side": "BUY",
"price": "40000.50000",
"timeInForce": "IOC",
"clientOrderId": "1234Abc"
}

}

Response:

{
"id": "1234567",
"data": [{
"orderId": 205343650954092544,
"clientOrderId": "",
"message": "",
"code": 200
}]
}

Cancel Multiple Orders

params same as Cancel Multiple Orders by Ids by call DELETE /orders/cancelByIds

Batch cancel one or many active orders in an account by IDs.

Request ParameterData TypeRequiredDescription
orderIdsStringNo, except clientOrderIds is null or emptyList of order id
clientOrderIdsStringNo, except orderIds is null or emptyList of clientOrderId
Response FieldData TypeDescription
orderIdStringthe order id
clientOrderIdStringclientOrderId of the order.
codeIntegerresponse code.200 is ok
messageStringresponse message.
Example:

Request:

{
"id": "1234567",
"event": "cancelOrders",
"params": {
"orderIds": ["170903943331844096", "170904091512410112"],
"clientOrderIds": ["45662xyz", "xasd2343"]
}
}

Response:

{
"id": "1234567",
"data": [{
"orderId": 170903943331844096,
"clientOrderId": "45662xyz",
"message": "",
"code": 200
}, {
"orderId": 170904091512410112,
"clientOrderId": "xasd2343",
"message": "",
"code": 200
}]
}

Cancel All Orders

params same as Cancel All Orders by call DELETE /orders

Batch cancel all orders in an account.

Response FieldData TypeDescription
orderIdStringthe order id
clientOrderIdStringclientOrderId of the order.
codeIntegerresponse code.200 is ok
messageStringresponse message.
Example:

Request:

{
"id": "1234567",
"event": "cancelAllOrders",
"params": {
}
}

Response:

{
"id": "1234567",
"data": [{
"orderId": 170903943331844096,
"clientOrderId": "45662xyz",
"message": "",
"code": 200
}, {
"orderId": 170904091512410112,
"clientOrderId": "xasd2343",
"message": "",
"code": 200
}]
}