liquidation-heatmap
The liquidation-heatmap Claude Code skill analyzes the distribution and concentration of leveraged position liquidation prices across different price levels to identify zones where cascading liquidations will accelerate price movements. Use this skill when trading leveraged instruments to locate support/resistance levels formed by liquidation clusters, anticipate stop-hunt zones where large liquidation concentrations will be triggered, and understand how forced selling or buying from liquidated positions creates profitable trading opportunities through price magnet effects.
git clone --depth 1 https://github.com/HKUDS/Vibe-Trading /tmp/liquidation-heatmap && cp -r /tmp/liquidation-heatmap/agent/src/skills/liquidation-heatmap ~/.claude/skills/liquidation-heatmapSKILL.md
# Liquidation Heatmap & Level Analysis
## Overview
Analyze the distribution of leveraged positions and their liquidation price levels to identify zones where forced selling/buying will accelerate price moves. Liquidation clusters act as "magnets" — price tends to be attracted toward large liquidation concentrations because market makers and whales profit from triggering cascading liquidations.
## Core Concepts
### 1. Liquidation Mechanics
**How liquidation works:**
```python
# Long position liquidation
long_liquidation_price = entry_price * (1 - 1/leverage + maintenance_margin)
# Short position liquidation
short_liquidation_price = entry_price * (1 + 1/leverage - maintenance_margin)
# Example: BTC long at $65,000, 10x leverage, 0.5% maintenance margin
# Liquidation: $65,000 * (1 - 1/10 + 0.005) = $58,825
# A 9.5% move against the position triggers liquidation
```
**Leverage and liquidation distance:**
| Leverage | Liquidation Distance (Long) | Liquidation Distance (Short) |
|----------|----------------------------|------------------------------|
| 2x | ~50% drop | ~50% rise |
| 5x | ~20% drop | ~20% rise |
| 10x | ~10% drop | ~10% rise |
| 20x | ~5% drop | ~5% rise |
| 50x | ~2% drop | ~2% rise |
| 100x | ~1% drop | ~1% rise |
### 2. Liquidation Heatmap Interpretation
A liquidation heatmap shows where liquidation orders are concentrated across different price levels, typically color-coded by density.
**Reading the heatmap:**
```
Price Level Long Liquidations Short Liquidations Interpretation
$70,000 ░░░░░░░░░░ ████████████████ Heavy short liquidation zone
$68,000 ░░░░ ██████████ Moderate short liquidation
$66,000 ███████ ███████ Balanced (current price area)
$64,000 ██████████ ░░░░ Moderate long liquidation
$62,000 ████████████████ ░░░░░░░░░░ Heavy long liquidation zone
```
**Key principles:**
1. **Liquidation clusters are magnets**: price tends to gravitate toward large liquidation pools because the forced orders provide liquidity for whales to fill their positions
2. **Liquidation cascades**: when a cluster gets hit, the forced selling/buying pushes price further, potentially triggering the next cluster → cascade effect
3. **After liquidation wipe**: once a large cluster is liquidated, that price level often becomes support/resistance (overleveraged positions are gone)
### 3. Liquidation Level Identification
```python
def identify_liquidation_clusters(open_interest_by_price, leverage_distribution):
"""
Estimate where liquidation clusters exist based on
open interest and leverage distribution.
"""
clusters = []
for price_level in price_range:
# Long liquidations: positions opened above this level with high leverage
long_liq_volume = estimate_long_liq_at_price(
open_interest_by_price, leverage_distribution, price_level
)
# Short liquidations: positions opened below this level with high leverage
short_liq_volume = estimate_short_liq_at_price(
open_interest_by_price, leverage_distribution, price_level
)
total = long_liq_volume + short_liq_volume
if total > significance_threshold:
clusters.append({
"price": price_level,
"long_liq": long_liq_volume,
"short_liq": short_liq_volume,
"type": "long" if long_liq_volume > short_liq_volume else "short",
"magnitude": total,
})
return sorted(clusters, key=lambda x: x["magnitude"], reverse=True)
```
### 4. Liquidation-Based Trading Signals
**Signal 1: Liquidation Magnet**
```python
def liquidation_magnet_signal(current_price, clusters):
"""
Price is likely to move toward the nearest large liquidation cluster.
"""
# Find nearest cluster above and below
above = [c for c in clusters if c["price"] > current_price]
below = [c for c in clusters if c["price"] < current_price]
nearest_above = min(above, key=lambda c: c["price"] - current_price) if above else None
nearest_below = min(below, key=lambda c: current_price - c["price"]) if below else None
if nearest_above and nearest_below:
above_magnitude = nearest_above["magnitude"]
below_magnitude = nearest_below["magnitude"]
if above_magnitude > below_magnitude * 2:
return "upward_magnet" # Larger cluster above → price likely moves up
elif below_magnitude > above_magnitude * 2:
return "downward_magnet" # Larger cluster below → price likely moves down
else:
return "balanced" # Both sides have similar clusters
```
**Signal 2: Cascade Risk**
```python
def cascade_risk(current_price, clusters, direction="down"):
"""
Assess risk of liquidation cascade — multiple clusters stacked close together.
"""
if direction == "down":
relevant = sorted([c for c in clusters if c["price"] < current_price and c["type"] == "long"],
key=lambda c: c["price"], reverse=True)
else:
relevant = sorted([c for c in clusters if c["price"] > current_price and c["type"] == "short"],
key=lambda c: c["price"])
if len(relevant) < 2:
return "low_cascade_risk"
# Check if clusters are stacked within 5% of each other
gaps = []
for i in range(len(relevant) - 1):
gap = abs(relevant[i]["price"] - relevant[i+1]["price"]) / current_price * 100
gaps.append(gap)
if min(gaps) < 2:
return "high_cascade_risk" # Clusters stacked tightly → cascade likely
elif min(gaps) < 5:
return "moderate_cascade_risk"
else:
return "low_cascade_risk"
```
**Signal 3: Post-Liquidation Support/Resistance**
```python
def post_liquidation_sr(price_history, liquidation_events):
"""
After a lProfessional finance research toolkit — backtesting (7 engines + benchmark comparison panel), factor analysis, Alpha Zoo (452 pre-built alphas across qlib158/alpha101/gtja191/academic), options pricing, 77 finance skills, 29 multi-agent swarm teams, Trade Journal analyzer, and Shadow Account (extract → backtest → render) across 7 data sources (tushare, yfinance, okx, akshare, mootdx, ccxt, futu).
ADR/H-share/A-share cross-listing premium analysis — track pricing gaps between US-listed ADRs, HK-listed H-shares, and A-shares for arbitrage signals, dual-listing valuation, and delisting risk assessment.
AKShare financial data aggregator (18k+ stars). Free, no API key. Covers A-shares, US, HK, futures, macro, forex. Primary fallback for tushare and yfinance.
Browse and bench the bundled alpha zoos — prebuilt cross-sectional factor libraries (Kakushadze 101, GTJA 191, Qlib 158, Fama-French / Carhart). Use when the user asks "which alphas exist", wants metadata on a named alpha, or wants to run IC/IR on a whole zoo over a universe.
A 股 ST/*ST 风险预测框架 — 基于最新中报/三季报或业绩预告/快报,预测下一财年是否会因营收、利润、净资产、分红不达标而被风险警示,并将新浪监管处罚记录作为独立证据面纳入风险等级。仅适用于 A 股,不预测财务造假。
Asset allocation theory and optimizer usage — MPT / Black-Litterman / risk budgeting / all-weather strategy, including guides for 4 optimizers and rebalancing rules.
Diagnose failed or underperforming backtests, locate the root cause, and fix the issue
Behavioral finance applications: theories of overreaction and underreaction, behavioral explanations for momentum and reversal, investor sentiment cycles, cognitive-bias checklists, and debiasing quantitative strategies.