/tradecraft:market-breadth-analyzerfrom tradecraft
Analyzes market breadth by classifying pairs as trending up, trending down, or ranging using ADX and EMA. Detects breadth divergence between price index and underlying participation. Useful for gauging overall market health and regime.
Ships in tradecraft. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
import pandas as pd, numpy as np
class MarketBreadthAnalyzer:
@staticmethod
def scan_breadth(pairs_data: dict, trend_threshold: float = 25) -> dict:
trending_up = []; trending_down = []; ranging = []
for sym, df in pairs_data.items():
if df.empty or len(df) < 50: continue
close = df["close"]
ema50 = close.ewm(span=50).mean().iloc[-1]
plus_dm = df["high"].diff().clip(lower=0).rolling(14).mean()
minus_dm = (-df["low"].diff()).clip(lower=0).rolling(14).mean()
atr = (df["high"] - df["low"]).rolling(14).mean()
dx = abs(plus_dm - minus_dm) / (plus_dm + minus_dm + 1e-10) * 100
adx = dx.rolling(14).mean().iloc[-1]
if adx > trend_threshold and close.iloc[-1] > ema50: trending_up.append(sym)
elif adx > trend_threshold and close.iloc[-1] < ema50: trending_down.append(sym)
else: ranging.append(sym)
total = len(trending_up) + len(trending_down) + len(ranging)
return {
"trending_up": trending_up, "trending_down": trending_down, "ranging": ranging,
"breadth_score": round((len(trending_up) - len(trending_down)) / max(total, 1) * 100, 1),
"pct_trending": round((len(trending_up) + len(trending_down)) / max(total, 1) * 100, 1),
"market_mode": "TRENDING" if len(trending_up) + len(trending_down) > len(ranging) else "RANGE-BOUND",
"bias": "RISK-ON" if len(trending_up) > len(trending_down) * 1.5 else "RISK-OFF" if len(trending_down) > len(trending_up) * 1.5 else "MIXED",
}
@staticmethod
def breadth_divergence(breadth_history: list[dict], index_prices: list[float]) -> dict:
"""Detect divergence between breadth and price index."""
if len(breadth_history) < 5 or len(index_prices) < 5:
return {"divergence": "INSUFFICIENT_DATA"}
recent_breadth = [b["breadth_score"] for b in breadth_history[-5:]]
breadth_trend = recent_breadth[-1] - recent_breadth[0]
price_trend = index_prices[-1] - index_prices[0]
if price_trend > 0 and breadth_trend < -10:
return {"divergence": "BEARISH", "signal": "Price rising but fewer pairs trending up — rally weakening"}
elif price_trend < 0 and breadth_trend > 10:
return {"divergence": "BULLISH", "signal": "Price falling but more pairs turning up — selloff exhausting"}
return {"divergence": "NONE", "signal": "Breadth confirms price action"}
| Breadth Score | Market Mode | Strategy Implication |
|---|---|---|
| > +60 | Strong risk-on | Trend-following, momentum strategies |
| +20 to +60 | Moderate bullish | Selective breakouts, reduced position size |
| -20 to +20 | Mixed/neutral | Mean reversion, range strategies |
| -60 to -20 | Moderate bearish | Short setups, defensive positioning |
| < -60 | Strong risk-off | Counter-trend caution, hedge existing longs |
breadth = MarketBreadthAnalyzer.scan_breadth(pairs_data)
print(f"Market: {breadth['market_mode']} | Bias: {breadth['bias']} | {breadth['pct_trending']}% trending")
div = MarketBreadthAnalyzer.breadth_divergence(breadth_history, dxy_prices)
if div["divergence"] != "NONE":
print(f"WARNING: {div['divergence']} divergence — {div['signal']}")
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub mahmoud20138/tradecraft --plugin tradecraft169 skills in this plugin
/agent-developmentThis skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins./agentic-storageAgentic storage architecture — persistent memory for AI agents using MCP, immutable versioning, sandboxing, and intent validation. Covers the stateless problem in LLM agents, RAG limitations (read-only), MCP protocol (JSON-RPC, resources, tools), storage safety layers, and agent file system design. Source: IBM Technology (Martin Keen), March 2026. Use this skill for "agentic storage", "agent memory", "persistent agent state", "MCP storage", "agent file system", "agent hard drive", "stateless agent problem", "agent work product", "immutable versioning", "agent sandboxing", "intent validation", "agent safety layers", "agent context window limits", "storage for AI agents", "agent persistence", "autonomous agent storage", "agent audit trail". Works with mcp-integration, trading-brain, agents, trade-psychology-coach.
Other plugins' skills for the same job