6 min read ยท March 4, 2026 ยท Purple Flea Team

Liquidation Hunting: How AI Agents Trade Market Cascades

In perpetual futures markets, liquidations are not random events. They cluster, they cascade, and they create some of the most predictable short-term price moves available in crypto trading. This guide teaches you how to build an AI agent that streams liquidation events in real time, scores cascade probability, and enters positions sized appropriately for the expected move.

In this guide
  1. What is a liquidation cascade?
  2. How cascades create predictable price moves
  3. Streaming liquidation events
  4. Filtering for high-probability setups
  5. Entry and exit mechanics
  6. Risk management
  7. Conclusion

What is a liquidation cascade?

Perpetual futures allow traders to use leverage โ€” a trader with $1,000 can open a $10,000 position at 10x leverage. When price moves 10% against them, their entire collateral is consumed and the exchange's liquidation engine forcibly closes their position at market price.

This forced close is itself a large market order. On BTC-PERP, a $5 million liquidated long is a $5 million market sell order hitting the order book immediately. If there are other leveraged longs clustered at nearby prices โ€” as there often are, because many traders use round numbers and similar technical levels for their entries โ€” the forced sell from the first liquidation drops price to the next cluster, triggering more liquidations, which drops price further. The cascade is self-reinforcing.

The cascade continues until one of two things happens: leveraged positions are exhausted at that price level, or a large buyer steps in and absorbs the selling. The end of a cascade is typically a sharp V-shaped bounce as the directional selling evaporates and the order book recovers.

How cascades create predictable price moves

Liquidation cascades are more predictable than most price moves for a structural reason: they are driven by mechanical forced selling, not by information. A trader selling because they know bad news is coming is adapting to information โ€” very hard to predict. A liquidation engine selling because a position's margin is exhausted is following a deterministic rule โ€” much easier to model.

The key inputs to cascade prediction are:

Important edge: Most retail traders see the big candle on their chart and react after the fact. An agent streaming liquidation events reacts within milliseconds of the first large liquidation โ€” before the cascade has developed fully.

Streaming liquidation events with Purple Flea

Purple Flea's liquidation API streams every forced close across 275 perpetual markets in real time. The stream is filterable by minimum size, market, and side. Here is a complete async stream handler that logs events and builds a rolling window to detect developing cascades:

Liquidation Stream with Rolling Window Python
import purpleflea
import asyncio
from collections import deque
import time

liq = purpleflea.LiquidationClient(api_key="YOUR_KEY")
trader = purpleflea.TradingClient(api_key="YOUR_KEY")

# Rolling 90-second window of liquidations per market
windows: dict[str, deque] = {}
WINDOW_SECS = 90
CASCADE_THRESHOLD_USD = 5_000_000 # $5M in window = cascade signal

async def handle(event):
    mkt = event['market']
    now = time.time()
    if mkt not in windows:
        windows[mkt] = deque()
    w = windows[mkt]
    w.append({'t': now, 'usd': event['size_usd'], 'side': event['side']})
    # Prune events outside window
    while w and now - w[0]['t'] > WINDOW_SECS:
        w.popleft()
    # Sum long vs short liquidations in window
    long_liq = sum(e['usd'] for e in w if e['side']=='long')
    if long_liq > CASCADE_THRESHOLD_USD:
        print(f"CASCADE DETECTED {mkt}: ${long_liq/1e6:.1f}M longs liquidated in 90s")
        await trader.place_order(market=mkt, side="sell", size=0.1, type="market")

async def main():
    async with liq.stream(min_usd=50_000) as stream:
        async for event in stream:
            await handle(event)

asyncio.run(main())

Filtering for high-probability setups

Not every large liquidation is worth trading. Many single liquidations are isolated โ€” a poorly risk-managed position getting blown out with no follow-through. The setups with the highest win rate share several characteristics:

Combining these filters typically narrows the signal from dozens of liquidation events per day to 3โ€“8 genuinely high-probability cascade trades. Quality over quantity is the correct posture for this strategy.

Entry and exit mechanics

Entry timing matters. The ideal entry is 5โ€“15 seconds after the first large liquidation event fires, once it is clear that follow-on liquidations are occurring. Entering too early risks catching a single isolated liquidation. Entering too late means much of the move has already occurred.

Cascade Trade with Auto-Exit Python
async def trade_cascade(market, side, size, cascade_score, liq_vol_usd):
    # Position size: scale with cascade score and volume
    confidence = cascade_score / 10 # 0.0 - 1.0
    vol_factor = min(liq_vol_usd / 10_000_000, 2.0) # cap at 2x for $20M+
    adj_size = round(size * confidence * vol_factor, 4)
    if adj_size < 0.001:
        return # too small, skip

    # Enter cascade trade
    entry = await trader.place_order(market=market, side=side,
        size=adj_size, type="market")
    entry_price = entry['avg_price']
    print(f"ENTERED {side} {adj_size} {market} @ ${entry_price:,.2f}")

    # Set stop-loss: 0.8% against entry, take-profit: 2% with entry
    flip = 1 if side == "sell" else -1
    stop_price = entry_price * (1 + flip * 0.008)
    tp_price = entry_price * (1 - flip * 0.02)
    await trader.set_stop_loss(market=market, trigger=stop_price)
    await trader.set_take_profit(market=market, trigger=tp_price)
    print(f" SL: ${stop_price:,.2f} | TP: ${tp_price:,.2f} | R:R 1:2.5")

Risk management

Cascade trading has a structural weakness: cascades can reverse violently. Once the fuel (leveraged positions to liquidate) is exhausted, the cascade ends โ€” often with a sharp snap-back as sellers are absorbed and the market bounces. An agent that stays in a cascade trade too long will give back all its profits on the reversal.

Warning: The most dangerous moment in cascade trading is right after the cascade appears to be slowing. This is when reversal risk is highest. Do not add to positions late in a cascade. Cut before the reversal, not after.

The core risk rules for cascade trading:

Conclusion

Liquidation cascade trading is one of the few strategies in crypto where the price move is mechanically driven rather than information-driven. By streaming liquidation events in real time, building rolling window accumulators, applying quality filters, and enforcing strict risk management, an AI agent can systematically profit from these moves while avoiding the dangerous reversal risk that burns most amateur cascade traders.

The Purple Flea liquidation API provides everything needed โ€” streaming events, cascade scores, heatmap data, and trading execution โ€” in a single integrated platform. Start with small sizes, measure your win rate per cascade score tier, and scale the parameters that perform best for your target markets.