The value of action specifies how the message should be handled; each action type is outlined in following sections with an example message. There are 6 action types.
- Partial
- Insert
- Update
- Delete
- Heartbeat
- Ping (keep-alive)
Partial Message
Action partial means the message is a new snapshot message, the client should remove the existing view of the order book and replace it with prices and sizes specified in the body of the message.
{
"table": "orderBookL2",
"action": "partial",
"symbol": "BTCUSD",
"bookVersionId": 1,
"sendTime": 1632330416488,
"keys": [
"symbol",
"id",
"side"
],
"data": [
{
"symbol": "BTCUSD",
"side": "Buy",
"size": "1.0",
"price": "43000.0"
}
]
}Insert Message
Action insert means insert or replace the current value of that price level with the new value; the value is the new absolute position for that price level. Only the size will be changed in the event of an order's price being amended the appropriate combination of insert/append and delete messages will be published to amend the appropriate levels.
{
"table": "orderBookL2",
"action": "insert",
"symbol": "BTCUSD",
"bookVersionId": 206,
"sendTime": 1632335161128,
"publishTime": 1632335161441,
"data": [
{
"symbol": "BTCUSD",
"side": "Sell",
"size": "177.0",
"price": "47228.0"
},
{
"symbol": "BTCUSD",
"side": "Sell",
"size": "102.0",
"price": "48935.0"
}
]
}Update Message
Action update means insert or replace the current value of that price level; the value is the new absolute position for that price level.
{
"table": "orderBookL2",
"action": "update",
"symbol": "BTCUSD",
"bookVersionId": 207,
"sendTime": 1632335161128,
"publishTime": 1632335161441,
"data": [
{
"symbol": "BTCUSD",
"side": "Sell",
"size": "177.0",
"price": "47228.0"
},
{
"symbol": "BTCUSD",
"side": "Sell",
"size": "102.0",
"price": "48935.0"
}
]
}Delete Message
Action delete means remove the price level; if the price level does not exist the message should be ignored.
{
"table": "orderBookL2",
"action": "delete",
"symbol": "BTCUSD",
"bookVersionId": 208,
"sendTime": 1632335161128,
"publishTime": 1632335161441,
"data": [
{
"symbol": "BTCUSD",
"side": "Sell",
"price": "46823.0"
}
]
}Heartbeat Message
Action heartbeat is a keep alive message sent every 30 seconds for each instrument if there are no updates in that time interval.
{
"table": "orderBookL2",
"timestamp": 1632334653163,
"action": "heartbeat",
"symbol": "BTCUSD"
}Ping Request-Response Keep-alive Message
To prevent connection timeouts, especially during low market activity, clients must participate in the OSL application-level heartbeat. The Websockes server periodically sends a ping message.
The client must respond with a pong to keep the connection alive
- Ping - server sends
{"action": "ping"} - Pong - client replies
{"action": "pong"}
