npx skills add ...
npx skills add tradermonty/claude-trading-skills --skill theme-detector
Detect and analyze trending market themes across sectors. Use when user asks about current market themes, trending sectors, sector rotation, thematic investing, what themes are hot or cold, or wants to identify bullish and bearish market narratives with lifecycle analysis.
npx skills add tradermonty/claude-trading-skills --skill theme-detector
This skill detects and ranks trending market themes by analyzing cross-sector momentum, volume, and breadth signals. It identifies both bullish (upward momentum) and bearish (downward pressure) themes, assesses lifecycle maturity (Emerging/Accelerating/Trending/Mature/Exhausting), and provides a confidence score combining quantitative data with narrative analysis.
3-Dimensional Scoring Model:
Key Features:
--scan-hits--history-fileExplicit Triggers:
Implicit Triggers:
When NOT to Use:
Required:
Cron / mixed-Python fallback: If the active python3 is older than 3.10, or a newer Hermes venv lacks the data-science dependencies, run the detector through uv with an explicit modern interpreter and temporary dependencies instead of editing the environment mid-cron:
Use this as a setup workaround, not as evidence that the detector is broken; still report FINVIZ/FMP/API-data caveats separately.
Optional API Keys:
FINVIZ Elite (recommended for full industry coverage and speed):
FMP API (optional, for P/E ratio valuation data):
The requirements include finvizfinance, PyYAML, pandas/numpy, requests, and
yfinance because normal public-mode execution imports or uses each of them.
Without FINVIZ Elite, the skill uses public FINVIZ scraping (limited to ~20 stocks per industry, slower rate limits).
Check that API keys are configured (see Prerequisites):
Run the main detection script:
Script Options:
Scan-hit input contract: --scan-hits accepts JSON, JSONL, or CSV. Rows may be pre-labeled with scan_type / scan_types, or raw rows with fields such as symbol, return_5d, change_pct, volume, avg_volume_50d, relative_volume, true_range, atr_20, atr_expansion, close_location, industry, sector, and theme_guess. A raw row can expand into multiple hits when it satisfies multiple rules.
Initial scan rules:
five_day_20pct: return_5d >= 20ep9m: volume >= 9,000,000, relative_volume >= 2.0, and change_pct >= 4range_expansion: change_pct >= 4, true_range / atr_20 >= 1.5 or atr_expansion >= 1.5, and close_location >= 0.75new_high: explicit new_high / is_new_high, or 52-week high evidencehigh_rs: rs_rating >= 90 or normalized relative_strength >= 0.90Narrative-score input contract: --narrative-scores is an offline JSON input, not a live WebSearch call. It accepts either {"Theme Name": 82} or {"themes": {"Theme Name": {"narrative_keyword_score": 82}}}. Missing narrative input leaves narrative_keyword_score as null and reduces theme_match_coverage; it does not fail the run.
Expected Execution Time:
The script generates two output files:
theme_detector_YYYY-MM-DD_HHMMSS.json - Structured data for programmatic usetheme_detector_YYYY-MM-DD_HHMMSS.md - Human-readable reportRead the JSON output to understand quantitative results:
For the top 5 themes (by Theme Heat score), execute WebSearch queries to confirm narrative strength:
Search Pattern:
Evaluate narrative signals:
Update Confidence levels based on findings:
Cross-reference detection results with knowledge bases:
Reference Documents to Consult:
references/cross_sector_themes.md - Theme definitions and constituent industriesreferences/thematic_etf_catalog.md - ETF exposure options by themereferences/theme_detection_methodology.md - Scoring model detailsreferences/finviz_industry_codes.md - Industry classification referenceAnalysis Framework:
For Hot Bullish Themes (Heat >= 70, Direction = Bullish):
For Hot Bearish Themes (Heat >= 70, Direction = Bearish):
For Emerging Themes (Heat 40-69, Lifecycle = Emerging):
For Exhausted Themes (Heat >= 60, Lifecycle = Exhausting):
Present the final report to the user using the report template structure:
Save the report to reports/ directory.
The skill generates two output files in the reports/ directory:
JSON Output (theme_detector_YYYY-MM-DD_HHMMSS.json):
Markdown Report (theme_detector_YYYY-MM-DD_HHMMSS.md):
Key Output Fields (per theme):
| Field | Description |
|---|---|
heat | 0-100 direction-neutral theme strength |
direction | "bullish" (LEAD) or "bearish" (LAG) |
stage | Emerging / Accelerating / Trending / Mature / Exhausting |
confidence | Low / Medium / High (script caps at Medium; WebSearch can elevate) |
representative_stocks | Top ticker symbols for the theme |
stock_details | Optional stock metric objects for the selected representatives |
proxy_etfs | Thematic ETF tickers (length = ETF count; higher = more crowded) |
theme_match_score | 0-100 evidence-quality score from industries, stock basket hits, proxy ETF confirmation, and optional narrative input |
theme_match_components | Inspectable sub-scores explaining the theme match |
leader_candidates | Evidence-ranked symbols for the theme; not entry/stop/invalidation guidance |
fresh_leadership_symbols | Current-run symbols with EP9M, range expansion, or new-high evidence |
extended_symbols | Current-run symbols with 5D+20% evidence; used as overextension evidence only |
theme_origin | "seed" (from YAML config) or "discovered" (auto-clustered) |
scripts/)Main Scripts:
theme_detector.py - Main orchestrator script
python3 theme_detector.py [options]theme_classifier.py - Maps industries to cross-sector themes
cross_sector_themes.mdfinviz_industry_scanner.py - FINVIZ industry data collection
calculators/lifecycle_calculator.py - Lifecycle maturity assessment
report_generator.py - Report output generation
references/)Knowledge Bases:
cross_sector_themes.md - Theme definitions with industries, ETFs, stocks, and matching criteriathematic_etf_catalog.md - Comprehensive thematic ETF catalog with counts per themefinviz_industry_codes.md - Complete FINVIZ industry-to-filter-code mappingtheme_detection_methodology.md - Technical documentation of the 3D scoring modelassets/)report_template.md - Markdown template for report generation with placeholder formatInstall requirements.txt before running the detector. --as-of-date is a
strict YYYY-MM-DD ceiling used by both uptrend freshness checks and provider
history windows. Because FINVIZ, quote, profile, and uptrend inputs are live
rather than PIT snapshots, a non-current --as-of-date fails closed. Freshness
counts XNYS sessions and excludes future-dated source rows.
| Feature | Elite Mode | Public Mode |
|---|---|---|
| Industry coverage | All ~145 industries | All ~145 industries |
| Stocks per industry | Full universe | ~20 stocks (page 1) |
| Rate limiting | 0.5s between requests | 2.0s between requests |
| Data freshness | Real-time | 15-min delayed |
| API key required | Yes ($39.50/mo) | No |
| Execution time | ~2-3 minutes | ~5-8 minutes |
Theme direction is determined by majority vote of constituent industries' relative rank:
_majority_direction() counts bullish vs. bearish industries within each theme; the majority winsDisplay mapping: "bullish" → LEAD, "bearish" → LAG (see report_generator.py::_direction_label())
A LEAD theme indicates relative outperformance of its constituent industries. A LAG theme may still have positive absolute returns — it indicates relative underperformance, not a short signal.
This analysis is for educational and informational purposes only.
Version: 1.0 Last Updated: 2026-02-16 API Requirements: FINVIZ Elite (recommended) or public mode (free); FMP API optional Execution Time: ~2-8 minutes depending on mode Output Formats: JSON + Markdown Themes Covered: 14+ cross-sector themes_