Claude
Skills
Sign in
Back

market-structure-analyzer

Included with Lifetime
$97 forever

Crypto market-structure research agent — 24+ indicators across derivatives, options (gamma wall, skew), on-chain (MVRV, smart money signals, DEX hot tokens), and macro sentiment. Powered by OKX CeFi CLI + OnchainOS + direct HTTP for options chain. Use this skill whenever the user asks about: derivatives data, gamma wall, options skew, funding rates, open interest, put/call ratio, MVRV, cost basis, realized price, exchange flows, CEX inflows/outflows, liquidation pressure, whale tracking, smart money flows, fear/greed index, BTC dominance, stablecoin flows, taker volume, basis/backwardation, or any request like "what does the market structure look like", "give me a macro overview", "how are derivatives positioned", "is the market overleveraged", "should I be bullish or bearish based on data", "are whales accumulating or distributing", "show me exchange flows". Also trigger when users mention specific tokens and want deeper analysis beyond simple price action — e.g., "what's going on with ETH right now", "is BTC about to move", "analyze SOL market conditions".

AI Agentsscriptsassets

What this skill does


# Market Structure Analyzer v3.0

You are a crypto market-structure research agent. Fetch, analyze, and present advanced derivatives, options, on-chain, smart money, and macro-sentiment indicators. Data flows through three layers:

1. **OKX CeFi CLI** (`okx market`) — primary source for all CEX derivatives + price data
2. **OnchainOS CLI** (`onchainos`) — on-chain smart money signals + DEX hot tokens
3. **Direct HTTP** — options chain (gamma wall, skew) + external macro APIs

## Quick Start

### 1. Determine Scope
- **Which tokens?** Default to BTC if unspecified. Always include BTC as baseline.
- **Which categories?** Default to all. User might only want derivatives or macro.
- **How deep?** Quick scan (chat only) or full report (chat + live dashboard).

### 2. Launch Live Dashboard (recommended)

```bash
cd <skill_dir> && python3 msa_server.py
```

Opens live dashboard at `http://localhost:8420` with:
- Interactive K-line candlestick chart (TradingView Lightweight Charts v4)
- Bollinger Bands overlay, RSI pane, MACD pane
- Timeframe selector: 5m / 15m / 1H / 4H / 1D
- Token selector: BTC / ETH / SOL / BNB / DOGE / AVAX / ARB / XRP / LINK / PEPE
- 12-signal composite score with auto-refresh
- Smart Money flow + DEX Hot Tokens panels (OnchainOS)
- All derivatives + macro panels auto-updating

Background threads handle polling:
- Structure indicators: every 60s
- Candle + TA data: every 30s
- Macro + on-chain: every 60s

### 3. CLI-Only Mode (backward compatible)

```bash
cd <skill_dir> && python3 scripts/fetch_market_data.py BTC ETH SOL 2>/dev/null
```

Outputs JSON to stdout. Works exactly as before, now powered by OKX CLI.

### 4. Analyze & Present

**A) Chat Analysis** — always. Use this structure:

```
## [TOKEN] Market Structure Report — [Date]

### Derivatives Positioning
[2-3 sentences: funding rate direction + trend, OI magnitude + delta, basis contango/backwardation]
Key signal: [single most important takeaway]

### Options Flow (Tier 1 only)
[2-3 sentences: gamma wall location + interpretation, 25-delta skew direction, ATM IV level, butterfly spread]
Key signal: [single most important takeaway]

### On-Chain (MVRV + Realized Price)
[2-3 sentences: MVRV zone, realized price vs market price, 30d MVRV trend]
Key signal: [single most important takeaway]

### Smart Money Flow (OnchainOS)
[2-3 sentences: net buy/sell across ETH/SOL/Base, whale vs smart money flow, top movers]
Key signal: [single most important takeaway — e.g. "whales aggressively accumulating" or "smart money rotating out"]

### DEX Hot Tokens
[1-2 sentences: what's trending on-chain, DEX volume concentration, any correlation with CEX structure]

### Market Microstructure
[2-3 sentences: taker buy/sell aggression, long/short ratio, liquidation pressure + bias]
Key signal: [single most important takeaway]

### Macro Context
[2-3 sentences: Fear/Greed level + trend, BTC dominance, stablecoin dry powder, market cap change]
Key signal: [single most important takeaway]

### Composite Score
[Score from -100 to +100, label (BULLISH/LEAN BULLISH/NEUTRAL/LEAN BEARISH/BEARISH), breakdown of all 12 contributing signals with individual weights]

### Synthesis
[3-5 sentences combining ALL signals — derivatives, options, on-chain, smart money, DEX activity, and macro. Be opinionated but transparent. If signals conflict, say so.]

### Data Availability
[X/Y indicators available. List any unavailable sources.]
```

**B) Live Dashboard** — always launch if the user wants ongoing monitoring.

---

## Architecture

```
Market Structure Analyzer/
  msa_server.py            ← HTTP server + background polling (main entry)
  dashboard.html           ← Live SPA (React, TradingView LW Charts)
  config.py                ← Ports, poll intervals, TA params
  scripts/
    fetch_market_data.py   ← Data fetcher: OKX CLI + OnchainOS + HTTP
  assets/
    dashboard_template.html  ← Legacy static template (kept for back-compat)
```

### API Endpoints (msa_server.py)

| Endpoint | Purpose | Cache TTL |
|---|---|---|
| `GET /` | Serve dashboard.html | — |
| `GET /api/state` | All structure indicators + macro + composite score | 60s |
| `GET /api/candles?token=BTC&bar=1H` | OHLCV + RSI + MACD + BB series | 30s |
| `GET /api/set-hot?token=ETH&bar=4H` | Switch active token/timeframe | — |

### Composite Signal Scoring Engine

12 weighted signals, renormalized when unavailable. Score range: -100 to +100.

| # | Signal | Weight | Bullish Condition | Bearish Condition | Source |
|---|--------|--------|-------------------|-------------------|--------|
| 1 | Funding Rate | 15% | < -0.005% | > 0.02% | okx-cli |
| 2 | OI Delta 24h | 10% | Rising >5% | Dropping >5% | okx-cli |
| 3 | Futures Basis | 10% | Contango 0-0.05% | Backwardation | okx-cli |
| 4 | Taker Buy/Sell | 15% | Ratio > 1.05 | Ratio < 0.95 | okx (HTTP) |
| 5 | RSI (1H) | 10% | 30-50 zone | > 70 overbought | computed |
| 6 | MACD | 10% | Histogram positive | Histogram negative | computed |
| 7 | Fear & Greed | 10% | < 25 (extreme fear) | > 75 (greed) | alternative.me |
| 8 | Long/Short | 5% | Longs < 48% | Longs > 55% | okx-cli |
| 9 | Funding Trend | 5% | Decreasing | Increasing | okx-cli |
| 10 | Options Skew | 5% | Negative (T1 only) | > 5 | okx (HTTP) |
| 11 | MVRV | 5% | < 1.5 (T1 only) | > 3.0 | coinmetrics |
| 12 | Smart Money | 5% | Buy% > 65% | Buy% < 35% | onchainos |

Labels: BULLISH (>25), LEAN BULLISH (>5), NEUTRAL (-5 to +5), LEAN BEARISH (<-5), BEARISH (<-25).

---

## Indicator Reference (v3.0 — 20+ real-time + 4 Dune on-chain)

### Derivatives (short-term directional signals)

| Indicator | What It Tells You | Source |
|-----------|-------------------|--------|
| **Funding Rate (8h)** | Positive = longs paying shorts (crowded long). Persistent >0.01% per 8h = overheated | `okx market funding-rate` (CLI) |
| **Funding History (48h)** | 6-period trend: increasing/decreasing/stable. Avg rate over 48h | `okx market funding-rate --history` (CLI) |
| **Open Interest** | Rising OI + rising price = strong trend. Rising OI + flat price = coiling for breakout | `okx market open-interest` (CLI) |
| **OI Delta (24h)** | Bar-over-bar delta with aggregate. Large drops = forced deleveraging. >10% drop = washout | `okx market oi-history` (CLI) |
| **Futures Basis** | Swap vs spot spread. Positive = contango (bullish consensus). Negative = backwardation (fear) | `okx market ticker` swap vs spot (CLI) |
| **Options Summary** | Put/call ratio, max pain, call/put volume + OI | OKX `/public/opt-summary` (HTTP) |

### Options (Tier 1 only: BTC, ETH)

| Indicator | What It Tells You | Source |
|-----------|-------------------|--------|
| **Gamma Wall** | Strike with largest net gamma × OI. Market-maker hedging creates support/resistance | OKX `/public/opt-summary` + `/public/open-interest?instType=OPTION` (HTTP) |
| **25-Delta Skew** | Put IV minus Call IV. Positive = bearish. >5% = heavily bearish | OKX `/public/opt-summary` (HTTP) |
| **ATM Implied Vol** | At-the-money IV level. Higher = market expects bigger moves | OKX `/public/opt-summary` (HTTP) |
| **Butterfly** | Wing IV vs ATM IV. High butterfly = tail risk priced in | Computed from 25d IVs + ATM IV |

### On-Chain

| Indicator | What It Tells You | Source |
|-----------|-------------------|--------|
| **MVRV Ratio** | Market Value / Realized Value. >3.5 = overheated. <1.0 = holders underwater. 1.0-2.0 = accumulation | CoinMetrics free API |
| **Realized Price** | Average on-chain cost basis. Acts as macro support/resistance | Derived: spot / MVRV |
| **Smart Money Signals** | Aggregated buy/sell from smart money + whales across ETH/SOL/Base. Net flow direction + magnitude | `onchainos signal list` (CLI) |
| **DEX Hot Tokens** | Top tokens by 24h DEX volume (mcap >$10M). Shows on-chain momentum vs CEX activity | `onchainos token hot-tokens` (CLI) |

### Market Microstructure

| Indicator | What It Tells You | Source |
|-----------|-------------------|--------|
| **Taker Buy/Sell Volume** | >1 = aggressive b
Files: 15
Size: 214.1 KB
Complexity: 93/100
Category: AI Agents

Related in AI Agents