Order commands
Create and cancel orders over the Pro WebSocket, in batch, and with a kill switch.
Authenticate before you send any of these commands on wss://ws.bit2me.com/v1/trading. Each command has its own message-per-second limit (limits); exceeding it aborts the connection.
Order changes caused by these commands also arrive on the my-orders, my-trades and executions channels. Open and cancel limits per market are on Rate limits, and error codes on Errors.
Add order
Creates one order. Limit: 10 per second. Sample: add-order.
{
"event": "add-order",
"symbol": "B2M/EUR",
"side": "buy",
"type": "limit",
"price": "0.001",
"stopPrice": "0",
"amount": "1000",
"clientOrderId": "c4022a5f-cfb3-46ff-9136-2739e34dd4e6"
}| Field | Values | Notes |
|---|---|---|
side | buy, sell | Required |
type | market, limit, stop-limit | Required. See order types |
price | Decimal string | Only for limit and stop-limit |
stopPrice | Decimal string | Only for stop-limit |
clientOrderId | String | Optional |
postOnly | true, false | Optional |
timeInForce | GTC, IOC, FOK | Optional |
amountInQuote | true, false | Optional |
The fields mean the same as on POST /v1/trading/order.
Response
{
"event": "added-order",
"symbol": "B2M/EUR",
"data": {
"id": "7d925e12-b12d-4bd9-aca3-963fb75eed93",
"userId": "7bd4cc22-7682-4e45-85b3-29386b979d75",
"side": "buy",
"symbol": "B2M/EUR",
"price": 0,
"orderAmount": 100,
"filledAmount": 0,
"status": "open",
"orderType": "market",
"cost": 0,
"createdAt": "2022-10-18T09:39:14.382Z",
"updatedAt": "2022-10-18T09:39:14.382Z",
"stopPrice": 0,
"postOnly": null,
"timeInForce": "GTC",
"feeAmount": 0,
"feeCurrency": null
}
}Error
{
"event": "added-order",
"symbol": "B2M/EUR",
"error": {
"code": "PRICE_LOWER_MARKET_MIN",
"minPrice": 0.001,
"message": "The price can not be lower than 0.001"
}
}Add orders (batch)
Creates up to 20 orders in one message. Limit: 1 per second. Each order takes the same fields as add-order.
{
"event": "add-orders",
"orders": [
{
"side": "buy",
"symbol": "B2M/EUR",
"price": "0.001",
"stopPrice": "0",
"amount": "1000",
"type": "limit",
"clientOrderId": "c4022a5f-cfb3-46ff-9136-2739e34dd4e6"
},
{
"side": "sell",
"symbol": "B2M/EUR",
"price": "0.5",
"stopPrice": "0",
"amount": "1000",
"type": "limit",
"clientOrderId": "90b4731e-5dba-4ef5-81f1-a22dcfd6c9ac"
}
]
}Response
Orders are accepted or rejected one by one: created orders are in ordersCreated and rejected ones in ordersFailedReasons, so check both lists.
{
"event": "added-orders",
"data": {
"userId": "72f5832e-8598-4cab-9412-19cc964c418a",
"ordersCreated": [
{
"id": "c19f6e71-5cff-4c22-b73b-ed0cf85b4973",
"userId": "72f5832e-8598-4cab-9412-19cc964c418a",
"side": "buy",
"symbol": "B2M/EUR",
"price": 0.001,
"orderAmount": 1000,
"filledAmount": 0,
"status": "open",
"orderType": "limit",
"cost": 0,
"createdAt": "2022-11-28T16:03:00.086Z",
"updatedAt": "2022-11-28T16:03:00.086Z",
"stopPrice": 0,
"clientOrderId": "c4022a5f-cfb3-46ff-9136-2739e34dd4e6",
"cancelReason": null,
"postOnly": null,
"timeInForce": "GTC",
"feeAmount": 0,
"feeCurrency": null
},
{
"id": "640ff823-fad9-4f49-ab6e-61ee9ee03fde",
"userId": "72f5832e-8598-4cab-9412-19cc964c418a",
"side": "sell",
"symbol": "B2M/EUR",
"price": 0.5,
"orderAmount": 1000,
"filledAmount": 0,
"status": "open",
"orderType": "limit",
"cost": 0,
"createdAt": "2022-11-28T16:03:00.117Z",
"updatedAt": "2022-11-28T16:03:00.117Z",
"stopPrice": 0,
"clientOrderId": "90b4731e-5dba-4ef5-81f1-a22dcfd6c9ac",
"cancelReason": null,
"postOnly": null,
"timeInForce": "GTC",
"feeAmount": 0,
"feeCurrency": null
}
],
"ordersFailedReasons": []
}
}Rejected order
{
"event": "added-orders",
"data": {
"userId": "7bd4cc22-7682-4e45-85b3-29386b979d75",
"ordersCreated": [],
"ordersFailedReasons": [
{
"symbol": "B2M/EUR",
"clientOrderId": "10b4731e-5dba-4ef5-81f1-a22dcfd6c9ad",
"error": {
"code": "PRICE_LOWER_MARKET_MIN",
"minPrice": 0.001,
"message": "The price can not be lower than 0.001"
}
}
]
}
}Cancel order
Cancels one of your orders. Limit: 10 per second.
{
"event": "cancel-order",
"orderId": "73352609-a885-4dc6-99c4-8a03e5df6bda"
}Response
{
"event": "canceled-order",
"symbol": "B2M/EUR",
"data": {
"orderId": "73352609-a885-4dc6-99c4-8a03e5df6bda",
"status": "cancelled"
}
}Error
{
"event": "canceled-order",
"orderId": "73352609-a885-4dc6-99c4-8a03e5df6bda",
"error": {
"code": "ORDER_NOT_FOUND",
"message": "The order with ID 73352609-a885-4dc6-99c4-8a03e5df6bda was not found"
}
}Cancel orders (batch)
Cancels up to 20 orders in one message. Limit: 1 per second.
{
"event": "cancel-orders",
"ordersId": [
"cab25117-47ce-4991-98d3-3a334afbc6a0",
"7e5c5ec4-2952-447c-ba0a-77637763ec71",
"a00ea616-aed4-44eb-9e05-b55c475e39d9",
"da1f00da-0cf0-4d9e-a3bf-fca9c26b3ecb"
]
}Response
Cancelled orders are in ordersDeleted; the rest are in ordersNotDeletedReasons with the reason.
{
"event": "canceled-orders",
"data": {
"userId": "2bf436fc-43e6-459a-b647-6b446f72ad96",
"ordersDeleted": [
{ "id": "cab25117-47ce-4991-98d3-3a334afbc6a0", "status": "cancelled" },
{ "id": "7e5c5ec4-2952-447c-ba0a-77637763ec71", "status": "cancelled" }
],
"ordersNotDeletedReasons": [
{
"id": "a00ea616-aed4-44eb-9e05-b55c475e39d9",
"reason": "The order with ID a00ea616-aed4-44eb-9e05-b55c475e39d9 was not found",
"error": {
"code": "ORDER_NOT_FOUND",
"message": "The order with ID a00ea616-aed4-44eb-9e05-b55c475e39d9 was not found"
}
},
{
"id": "da1f00da-0cf0-4d9e-a3bf-fca9c26b3ecb",
"reason": "The order with ID da1f00da-0cf0-4d9e-a3bf-fca9c26b3ecb was not found",
"error": {
"code": "ORDER_NOT_FOUND",
"message": "The order with ID da1f00da-0cf0-4d9e-a3bf-fca9c26b3ecb was not found"
}
}
]
}
}Cancel all orders
Cancels all your orders on a symbol. Send the optional side (buy or sell) to cancel only that side. Limit: 1 per second.
{
"event": "cancel-all-orders",
"symbol": "B2M/EUR",
"side": "buy"
}Response
{
"event": "canceled-all-orders",
"symbol": "B2M/EUR",
"data": {
"userId": "2bf436fc-43e6-459a-b647-6b446f72ad96",
"cancelledOrders": ["c5dfb28b-a306-4682-acdd-1271a299ca6b"]
}
}Kill switch: auto-cancel on disconnection
Cancels all your open orders if the connection goes silent. Limit: 5 per second.
Send the command with a timeout in seconds and keep sending it before that timeout expires. If the server does not receive another auto-cancel-orders-on-disconnection within timeout seconds, it cancels your open orders created within the window set by deleteLast.
{
"event": "auto-cancel-orders-on-disconnection",
"symbol": "B2M/EUR",
"timeout": 5,
"deleteLast": {
"value": 10,
"unit": "m"
}
}| Field | Notes |
|---|---|
timeout | Seconds. 0 or a negative value disables the auto-cancel |
deleteLast | Optional. Only orders created within this time are cancelled |
deleteLast.unit | s (seconds), m (minutes), h (hours), d (days) |
Response
triggerTime is when the orders will be cancelled unless you renew the command.
{
"event": "auto-cancel-orders-on-disconnection",
"status": "ok",
"currentTime": "2022-11-24T15:51:26.499Z",
"triggerTime": "2022-11-24T15:51:31.499Z"
}