Trade requests
use webScoket to create or cancel orders.Parameters same as REST API
Request Parameter | Data Type | Required | Description |
---|---|---|---|
id | String | false | request id,if responds, this id is returned max, length 50 |
event | String | true | trade events, enumerated value eg: createOrder cancelOrders ... |
params | Json | true | event 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 Parameter | Data Type | Required | Description |
---|---|---|---|
symbol | String | true | The symbol to trade, like BTC_USDT |
side | String | true | BUY, SELL |
timeInForce | String | false | GTC, IOC, FOK (Default: GTC) |
type | String | false | MARKET, LIMIT, LIMIT_MAKER (for placing post only orders). Default type is MARKET. |
accountType | String | false | SPOT is the default and only supported one. |
price | String | false | Price is required for non-market orders |
quantity | String | false | Base units for the order. Quantity is required for MARKET SELL or any LIMIT orders |
amount | String | false | Quote units for the order. Amount is required for MARKET BUY order |
clientOrderId | String | false | Maximum 64-character length.* |
allowBorrow | Boolean | false | allow order to be placed by borrowing funds (Default: false) |
stpMode | String | false | self-trade prevention. Defaults to EXPIRE_TAKER. None: enable self-trade; EXPIRE_TAKER: Taker order will be canceled when self-trade happens |
slippageTolerance | String | false | Used to control the maximum slippage ratio, the value range is greater than 0 and less than 1 |
Response Field | Data Type | Description |
---|---|---|
id | String | order id |
clientOrderId | String | clientOrderId user specifies in request or an empty string. |
message | String | message |
code | int | 200 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 Parameter | Data Type | Required | Description |
---|---|---|---|
orderIds | String | No, except clientOrderIds is null or empty | List of order id |
clientOrderIds | String | No, except orderIds is null or empty | List of clientOrderId |
Response Field | Data Type | Description |
---|---|---|
orderId | String | the order id |
clientOrderId | String | clientOrderId of the order. |
code | Integer | response code.200 is ok |
message | String | response 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 Field | Data Type | Description |
---|---|---|
orderId | String | the order id |
clientOrderId | String | clientOrderId of the order. |
code | Integer | response code.200 is ok |
message | String | response 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
}]
}