Skip to main content

General WSS information

Base Address

wss://stream.monochrome.exchange/public

Request Headers

The request header of the compression extension protocol must be added. Sec-Websocket-Extensions:permessage-deflate

Request message format

subscribe
unsubscribe

Response message format

format
Response-success
response-token invalid

Push message format

format
Example of transaction record (real-time push message)

Heartbeat

Each link of the client needs to send a text “ping” periodically, and the server will reply to the text “pong”. If the server does not receive a ping message from the client within 1 minute, it will actively disconnect the link.

Subscription parameters

format {topic}@{arg},{arg},…

Orderbook manage

How to manage a local order book correctly 1.Open a stream to wss://stream.monochrome.exchange/public , depth_update@btc_usdt 2.Buffer the events you receive from the stream. 3.Get a depth snapshot from https://sapi.monochrome.exchange/v4/public/depth?symbol=btc_usdt&limit=500 4.Drop any event where i is <= lastUpdateId in the snapshot. 5.The first processed event should have fi <= lastUpdateId+1 AND i >= lastUpdateId+1. 6.While listening to the stream, each new event’s fi should be equal to the previous event’s i+1. 7.The data in each event is the absolute quantity for a price level. 8.If the quantity is 0, remove the price level. 9.Receiving an event that removes a price level that is not in your local order book can happen and is normal. Note: Due to depth snapshots having a limit on the number of price levels, a price level outside of the initial snapshot that doesn’t have a quantity change won’t have an update in the Diff. Depth Stream. Consequently, those price levels will not be visible in the local order book even when applying all updates from the Diff. Depth Stream correctly and cause the local order book to have some slight differences with the real order book. However, for most use cases the depth limit of 500 is enough to understand the market and trade effectively.

Trade record

request format: trade@{symbol} eg: trade@btc_usdt rate: real
Response

K-line

request format: kline@{symbol},{interval} interval: 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M eg: kline@btc_usdt,5m rate: 1000ms
Response

Limited depth

request format: depth@{symbol},{levels} levels: 5, 10, 20, 50 eg: depth@btc_usdt,20 rate: 1000ms
Response

Incremental depth

request format: depth_update@{symbol} eg: depth_update@btc_usdt rate: 100ms
Response

ticker

request format: ticker@{symbol} eg: ticker@btc_usdt rate: 1000ms
Response