skills/theme-detector/SKILL.md
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 skillsauth add kavi-lin/stock theme-detectorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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:
Explicit Triggers:
Implicit Triggers:
When NOT to Use:
Check for required API keys and dependencies:
# Check for FINVIZ Elite API key (optional but recommended)
echo $FINVIZ_API_KEY
# Check for FMP API key (optional, used for valuation metrics)
echo $FMP_API_KEY
Requirements:
requests, beautifulsoup4, lxml, pandas, numpy, yfinanceOptional dependencies:
finvizfinance (for FINVIZ Elite mode)PyYAML (for --themes-config custom themes)Installation:
pip install requests beautifulsoup4 lxml pandas numpy yfinance
Run the main detection script:
python3 skills/theme-detector/scripts/theme_detector.py \
--output-dir reports/
Script Options:
# Full run (public FINVIZ mode, no API key required)
python3 skills/theme-detector/scripts/theme_detector.py \
--output-dir reports/
# With FINVIZ Elite API key
python3 skills/theme-detector/scripts/theme_detector.py \
--finviz-api-key $FINVIZ_API_KEY \
--output-dir reports/
# With FMP API key for enhanced stock data
python3 skills/theme-detector/scripts/theme_detector.py \
--fmp-api-key $FMP_API_KEY \
--output-dir reports/
# Custom limits
python3 skills/theme-detector/scripts/theme_detector.py \
--max-themes 5 \
--max-stocks-per-theme 10 \
--output-dir reports/
# Explicit FINVIZ mode
python3 skills/theme-detector/scripts/theme_detector.py \
--finviz-mode public \
--output-dir reports/
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:
# Find the latest report
ls -lt reports/theme_detector_*.json | head -1
# Read the JSON output
cat reports/theme_detector_YYYY-MM-DD_HHMMSS.json
Step 4 is optional. Quant output from Step 2 already caps confidence at
Medium — that is the production default consumed by bridge.py, Dashboard
sector card, and investment protocol. The sidecar described here can elevate
top themes to High when material narrative support exists.
Codex-compatible path (v3.14.2+) — router-driven script:
python3 skills/theme-detector/scripts/narrative_confirm.py # latest cache, top-5
python3 skills/theme-detector/scripts/narrative_confirm.py --top-n 8
The script:
scripts/_shared/model_router.run_role("narrative_confirm", ...)
— any of claude / gemini / codex can drive it.cache/theme_detector_<ts>.narrative.json (sidecar) with
confirmations[], narrate_mode = llm | skipped, model_used, and a
bumped_count summary.narrate_mode = skipped with empty bumps — never raises.Claude WebSearch path (legacy) — for sessions running under Claude Code with WebSearch / WebFetch available, the analyst may still do manual searches and elevate Confidence in-conversation. The sidecar is preferred because it leaves a deterministic audit trail, but both paths produce the same downstream effect.
Downstream consumption:
confidence from theme_detector_<ts>.json (capped at Medium).theme_detector_<ts>.narrative.json exists AND a confirmation row has
confidence_bump == "medium->high", bump that theme to High.Confidence ladder:
medium->high = High confidencenone = Medium (possible momentum divergence)medium->high = Medium (narrative may lead price)none = LowCross-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:
# Theme Detection Report
**Date:** YYYY-MM-DD
**Mode:** FINVIZ Elite / Public
**Themes Analyzed:** N
**Data Quality:** [note any limitations]
## Theme Dashboard
[Top themes table with Heat, Direction, Lifecycle, Confidence]
## Bullish Themes Detail
[Detailed analysis of bullish themes sorted by Heat]
## Bearish Themes Detail
[Detailed analysis of bearish themes sorted by Heat]
## All Themes Summary
[Complete theme ranking table]
## Industry Rankings
[Top performing and worst performing industries]
## Sector Uptrend Ratios
[Sector-level aggregation if uptrend data available]
## Methodology Notes
[Brief explanation of scoring model]
Save the report to reports/ directory.
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 format| 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
development
# earnings-analyst — 個股財報深度分析 > **Trigger**: `財報 [TICKER]` > **Version**: V1.0 > **Data Source**: FMP HTTP REST(`$FMP_API_KEY`) ## 目的 針對單一個股產出**深度財報分析報告**(逐季趨勢、品質指標、估值、分析師共識),涵蓋 sector V1.4 與 `分析 [TICKER]` 既有 protocol **沒有**的「財報層級」深潛內容。 ## 與既有 skill 的差異 | Skill | 重點 | 觸發 | |---|---|---| | `us-stock-analysis` | 估值/技術/情緒 snapshot(yfinance + FMP partial) | Phase 2 fundamentals lane | | `earnings-valuation-forecaster` | 12M 目標價 3×3 敏感度 | ad-hoc / earnings 前 14 天 | | `earnings-trade-analyzer` |
testing
Daily Top N hot themes × Top M short-term movers per theme. Combines theme-detector heat scoring (medium-term) with short-term-target predictions (1d/5d/15d) into a "Tactical Opportunity Radar" recommendation log. Tags concentration WARNING when ≥2 picks share theme. Records FRED + market regime snapshot at recommendation time for future backtest cross-tabs. Standalone — not auto-wired into investment_protocol. Use for daily watchlist refresh / Dashboard推薦面板feed / batch screening across hot themes.
testing
Short-term (1d / 5d / 15d) directional projection for a US stock — "Tactical Opportunity Radar". Outputs target range + confidence breakdown + benchmark-relative alpha + trading meta (stop / position size hint / exit trigger). Each horizon uses independent weights from config/weights.yaml. Refuses to project when source data is stale (returns insufficient_data with reasons). Hard-clamped to prevent cold-start absurd predictions. Use when caller wants short-term directional bias on a specific ticker, NOT for long-term valuation (use earnings-valuation-forecaster for 12-month). Standalone — not auto-wired into investment_protocol.
tools
Shared Finnhub API client used by other skills. Provides rate-limited (60/min), cached, retry-aware access to 17 Finnhub endpoints covering quotes, OHLCV, fundamentals, earnings calendar, earnings surprises, insider transactions, recommendation history, price targets, upgrades/downgrades, dividends, splits, IPOs, and SEC filings. Also exports adapters that normalize Finnhub raw responses into FMP-compatible shapes so that downstream code can swap providers without changing call sites. Use when another skill needs Finnhub data or when building a unified provider layer.