You are offline

Switched to Home view. Returning to your route when internet connects.

← Back to Knowledge Center
Coding
Published:Nov 28, 2026
•
Updated:Nov 28, 2026
•7 min read

What the public liquidation streams of Binance, OKX, Bybit and Bitget do not tell you

What the public liquidation streams of Binance, OKX, Bybit and Bitget do not tell you
Rahul Sharma

Rahul Sharma

Contributor & Platform Mentor

Writes about programming, productivity, and online learning.

Hey everyone! Just wanted to share a few thoughts on this topic.

I run liquidation.lol).result.list.map(t => t.symbol);

for (let i = 0; i < symbols.length; i += 50) { const chunk = symbols.slice(i, i + 50); ws.send(JSON.stringify({ op: 'subscribe', args: chunk.map(s => 'allLiquidation.' + s) })); }

Code

Keep a short hard-coded fallback list (BTC, ETH and a few more) for the day that REST call fails, so a bad start does not leave you blind.

## 1. "Side" is the side of the forced order, not of the position

This is the mistake that makes a feed look right and be exactly backwards.

When a long is liquidated, the exchange sells it. So on Binance a liquidation with `S: "SELL"` is a liquidated **long**. OKX and Bybit follow the same logic:

```js
// Binance: o.S is the side of the forced order
const side = o.S === 'SELL' ? 'LONG' : 'SHORT';

// OKX: details[].side is the side of the forced closing order
const side = det.side === 'sell' ? 'LONG' : 'SHORT';

// Bybit
const side = d.S === 'Sell' ? 'LONG' : 'SHORT';

tbh, bitget is the one where our mapping goes the other way: in its `liquidation` topic we read `side: "buy"` as a liquidated long. Do not take my word or the docs' word for any of the four. Wait for a sharp drop, when you know longs are the ones being wiped, and check that your feed agrees with the chart.

2. Size is not always a number of coins

basically, binance USDT-M is the easy case: quantity times price is the dollar value.

OKX reports `sz` in **contracts**. A contract is worth a different amount on every instrument, and linear and inverse contracts are computed differently. You need the contract specs from `/api/v5/public/instruments?instType=SWAP` before you can price a single event:

Js
if (spec.ctType === 'inverse') {
in my experience, usd = sz * spec.ctVal;          // inverse: the contract value is already in USD
quantity = usd / px;
} else {
quantity = sz * spec.ctVal;     // linear: the contract value is in coins
usd = quantity * px;
}

Two rules I would not skip:

  • If an instrument is not in your spec table, drop the event. A fallback of ctVal = 1 produces liquidations that are wrong by a factor of 10 or 1,000, and one of those becomes your "biggest liquidation of the day".
  • Reload the spec table every hour. New listings appear without warning.

basically, bybit inverse has its own version of this: the value field is already in USD, so the coin quantity is value divided by price, not the other way round. Bitget reports a dollar `amount` as well.

3. A connected socket can be dead

For four days in May our Binance connection was open, the process manager showed it online, the log said "connected", and not one event arrived. The feeder recorded 25,940 Binance events on May 20, 20,778 on May 21, then zero from May 22 to May 25 until someone restarted it by hand.

The socket was half-open: no `close` event, no `error` event, no data. Reconnect-on-close logic never fires, because nothing closes.

The fix is a watchdog on message flow, not on connection state:

Js
let lastMsg = Date.now();
ws.on('message', () => { lastMsg = Date.now(); /* ... */ });

setInterval(() => {
if (Date.now() - lastMsg > 10 * 60 * 1000) ws.terminate();   // 10 minutes of silence
}, 30 * 1000);

`terminate()` triggers the normal close path, which reconnects. Pair it with exponential backoff (ours starts at 3 seconds, doubles up to 60, and resets once a connection has stayed healthy for a minute), or a flapping connection will hammer the exchange and earn you a soft IP block.

4. Every exchange wants a different heartbeat
  • Binance sometimes sends the literal text ping as an application message, separate from WebSocket ping frames. Answer with the text pong.
    in my experience, - OKX expects you to send the text ping. We do it every 25 seconds and it answers pong.
  • Bybit wants JSON: {"op":"ping"}, every 20 seconds.
    like, - Bitget takes the text ping every 25 seconds.

Whatever you do, filter the `pong` replies out before `JSON.parse`, or your error handler eats them silently and you never notice.

5. The streams are a sample, not a ledger

Binance's liquidation stream publishes at most one liquidation per symbol per second. During a cascade, when dozens of positions on the same pair are closed inside the same second, you see one of them.

So every total built from public streams is a **lower bound**. This is true for every tracker that uses them, including mine, and it is why the site says so on its data pages. It also means two trackers will never show the same number, and neither is "the" number. An exchange's own settlement data would be, and that is not public.

Within that limit, the numbers are still useful for comparing one day with another. On November 27, 2026 the feed recorded $328.4M liquidated across the four exchanges, 59% of it longs. The heaviest day since recording began is August 19, 2026 at $1.75B. The full list is on the biggest liquidation days and drops any key it has seen in the last 2 minutes. The server removes duplicates again over a 10-minute window, which also makes it safe to re-send a batch after a failed request.

For OKX, put the size in the key. Several distinct fills can share one timestamp, and without the size you merge them into one.

We also drop everything under $50. Below that it is noise.

7. Batch, or the hosting bill finds you

The feeder does not forward events one by one. It collects them and sends one POST every 8 seconds with up to 500 events in it. The site runs on Cloudflare Workers with a Durable Object doing the aggregation, and one request per event would burn through the daily request budget on any busy day. One request per 8 seconds is a fixed, predictable cost, whether the market is asleep or in free fall.

Bound the queue as well (ours is capped at 5,000 events), and cap retries per batch, so an outage on the receiving side cannot grow memory forever.

The one I got wrong: Hyperliquid

basically, hyperliquid has no liquidation stream at all. The trick you will find is to subscribe to the `trades` channel per coin and keep only the fills whose transaction hash is all zeros, on the idea that a normal trade carries a real hash and a liquidation carries the zero hash.

I built that. Two things went wrong.

First, if you fire all the subscriptions at once, most are dropped without an error. They have to be spaced out, about 200 ms apart.

Second, and this is the one that matters: the zero hash is not only liquidations. TWAP fills carry the all-zero hash as well. It is in the API reference, in the description of the `hash` field, and I had not read it. So the filter was counting ordinary TWAP order slices as liquidations. I switched it off, and Hyperliquid is not in the site's totals today. A wrong number is worse than a missing one.

What I would tell myself on day one

basically, 1. Check the long/short mapping against a real crash before anything else. 2. Never guess a contract size. honestly, 3. Watch for silence, not for disconnects. 4. Call your totals a lower bound, because they are. 5. If a filter looks too clever, read the docs for what else matches it.

The live feed is at [liquidation.lol]( If you want the numbers on your own page there is a free [embeddable widget]( that needs no signup and no JavaScript. And if you have ever wondered why a liquidation heatmap and the real liquidations disagree, [this page compares the two]( on a real crash day.

Let me know if you've run into this as well. Happy coding!

Comments (0)

No comments yet. Be the first to join the dialogue!