Perps L2 Grouped
l2:perps:grouped
Price-bucketed depth snapshot for depth chart rendering. Conservative bucketing: bids floor, asks ceil — each side rounds away from the spread so grouped depth never overstates near-spread liquidity. Published every 250ms when the book has updates.
Channel: l2:perps:grouped:{bucket}:{instrument}
Example: l2:perps:grouped:0.5:ETH_USDC-PERPETUAL
Payload
{
"timestamp": 1704067200000,
"bids": [
["2495", "15000.5", "15000.5"],
["2494.5", "8200", "23200.5"]
],
"asks": [
["2495.5", "12000", "12000"],
["2496", "9500", "21500"]
]
}| Field | Type | Description |
|---|---|---|
timestamp | integer | Unix timestamp in milliseconds |
bids | array | Bid levels, best (highest) first. Each: [price, amount, cumulative] |
asks | array | Ask levels, best (lowest) first. Each: [price, amount, cumulative] |
Level array elements:
| Index | Type | Description |
|---|---|---|
| 0 | string | Bucket boundary price (bids floored, asks ceiled) |
| 1 | string | Total amount at this bucket (notional USD) |
| 2 | string | Cumulative amount from best to this level |
Available Buckets
| Instrument | Buckets |
|---|---|
ETH_USDC-PERPETUAL | 0.1, 0.2, 0.5, 1, 10, 100 |
BTC_USDC-PERPETUAL | 1, 2, 5, 10, 100, 1000 |
Subscribe — Raw WebSocket
const ws = new WebSocket("wss://staging.kyan.sh/stream/websocket");
let id = 0;
ws.onopen = () => ws.send(JSON.stringify({ id: ++id, connect: {} }));
ws.onmessage = (e) => {
const msg = JSON.parse(e.data);
if (Object.keys(msg).length === 0) { ws.send("{}"); return; } // ping
if (msg.id === 1) {
ws.send(JSON.stringify({
id: ++id,
subscribe: { channel: "l2:perps:grouped:0.5:ETH_USDC-PERPETUAL", recover: true },
}));
return;
}
if (msg.push?.pub) {
const { timestamp, bids, asks } = msg.push.pub.data;
// Each level: [bucketPrice, amount, cumulativeAmount] — all strings
// bids: price floored to bucket boundary
// asks: price ceiled to bucket boundary
}
};Recovery
Subscribe with since: {} to receive the last known snapshot on subscribe. On reconnect, the SDK automatically recovers.
Related channels
Channels providing related data.
| Channel | Why |
|---|---|
| Perps L2 | Raw ungrouped depth with exact prices and order counts. This channel is a bucketed aggregation of that data. |
| Perps BBO | Exact top-of-book prices. Grouped bucketing rounds away from the spread, so the first grouped level may differ from BBO. |
| Index Price | Spot price for the underlying pair. |
Updated about 2 months ago
