backtest-expert
Expert guidance for systematic backtesting of trading strategies. Use when developing, testing, stress-testing, or validating…
Analyze historical downtrend durations and generate interactive HTML histograms showing typical correction lengths by sector and market cap.
Claude Code
$ npx -y skills add tradermonty/claude-trading-skills --skill downtrend-duration-analyzer --agent claude-code
Codex
$ npx skills add tradermonty/claude-trading-skills --skill downtrend-duration-analyzer -a codex -y
Cursor
$ npx skills add tradermonty/claude-trading-skills --skill downtrend-duration-analyzer -a cursor -y
Gemini CLI
$ npx skills add tradermonty/claude-trading-skills --skill downtrend-duration-analyzer -a gemini-cli -y
GitHub Copilot
$ npx skills add tradermonty/claude-trading-skills --skill downtrend-duration-analyzer -a github-copilot -y
OpenCode
$ npx skills add tradermonty/claude-trading-skills --skill downtrend-duration-analyzer -a opencode -y
Windsurf
$ npx skills add tradermonty/claude-trading-skills --skill downtrend-duration-analyzer -a windsurf -y
name: downtrend-duration-analyzer description: Analyze historical downtrend durations and generate interactive HTML histograms showing typical correction lengths by sector and market cap.
Analyze historical price data to identify downtrend periods (peak-to-trough) and build statistical distributions of correction durations. Generate interactive HTML visualizations with histograms segmented by sector and market cap to help traders understand typical recovery timeframes and set realistic expectations for mean reversion strategies.
The generated FMP client calls `/stable/company-screener` and `/stable/historical-price-eod/full` only. A legacy-only plan can no longer use the removed v3 fallback. The stock filters and explicit historical date range are unchanged; stable flat OHLCV rows are sorted oldest first without a row limit. Empty history stays empty, and malformed history is reported and skipped without filling missing prices. One HTTP session is reused for the run and closed on exit. Shared transport adds 0.3-second pacing, one 60-second retry on HTTP 429, and one retry on malformed JSON; credentials are redacted in errors.
Run the analysis script to fetch OHLC data for a universe of stocks and identify downtrend periods.
python3 skills/downtrend-duration-analyzer/scripts/analyze_downtrends.py \ --sector "Technology" \ --lookback-years 5 \ --output-dir reports/
The script automatically: 1. Identifies local peaks and troughs using rolling window analysis 2. Calculates duration (trading days) and depth (% decline) for each downtrend 3. Segments results by sector and market cap tier (Mega, Large, Mid, Small) 4. Computes summary statistics (median, mean, percentiles)
python3 skills/downtrend-duration-analyzer/scripts/generate_histogram_html.py \ --input reports/downtrend_analysis_*.json \ --output-dir reports/
This creates an interactive HTML file with:
Load the generated markdown report to interpret the findings:
{
"schema_version": "1.0",
"analysis_date": "2026-03-28T07:00:00Z",
"parameters": {
"lookback_years": 5,
"sector_filter": "Technology",
"peak_window": 20,
"trough_window": 20
},
"summary": {
"total_downtrends": 1234,
"median_duration_days": 18,
"mean_duration_days": 24.5,
"p25_duration_days": 10,
"p75_duration_days": 32,
"p90_duration_days": 55
},
"by_sector": {
"Technology": {
"count": 456,
"median_days": 15,
"mean_days": 20.3
}
},
"by_market_cap": {
"Mega": {"count": 200, "median_days": 12},
"Large": {"count": 300, "median_days": 16},
"Mid": {"count": 400, "median_days": 22},
"Small": {"count": 334, "median_days": 28}
},
"downtrends": [
{
"symbol": "AAPL",
"sector": "Technology",
"market_cap_tier": "Mega",
"peak_date": "2025-01-15",
"trough_date": "2025-02-10",
"duration_days": 18,
"depth_pct": -12.5
}
]
}# Downtrend Duration Analysis **Date**: 2026-03-28 **Lookback**: 5 years **Sector**: Technology ## Summary Statistics | Metric | Value | |--------|-------| | Total Downtrends | 1,234 | | Median Duration | 18 days | | Mean Duration | 24.5 days | | 25th Percentile | 10 days | | 75th Percentile | 32 days | | 90th Percentile | 55 days | ## By Market Cap Tier | Tier | Count | Median | Mean | |------|-------|--------|------| | Mega ($200B+) | 200 | 12 days | 15.2 days | | Large ($10-200B) | 300 | 16 days | 20.1 days | | Mid ($2-10B) | 400 | 22 days | 28.4 days | | Small (<$2B) | 334 | 28 days | 35.6 days | ## Key Insights 1. Larger companies recover faster from corrections 2. Technology sector shows shorter median correction than market average 3. 90% of corrections resolve within 55 trading days
Interactive histogram saved to `reports/downtrend_histogram_YYYY-MM-DD.html` with:
Reports are saved to `reports/` with filenames:
1. **Statistical Rigor**: Use robust peak/trough detection to avoid noise-induced false signals 2. **Segmentation Matters**: Always analyze by sector and market cap; averages
Data handling: Privacy policy · Security policy Claude Trading Skills started as a personal project to use AI to improve my own trading process. Claude Trading Skills is a Claude Skills-based trading workflow toolkit for time-constrained individual investors.
Expert guidance for systematic backtesting of trading strategies. Use when developing, testing, stress-testing, or validating…
This skill should be used when analyzing market breadth charts, specifically the S&P 500 Breadth Index (200-Day MA based) and the…
Generate Minervini-style breakout trade plans from VCP screener output with worst-case risk calculation, portfolio heat…
Screen US stocks using William O'Neil's CANSLIM growth stock methodology. Use when user requests CANSLIM stock screening, growth…
Synthesize the three Jason Shapiro contrarian-pipeline verdicts (COT crowding, news-reaction failure, weekly price-action…
Detect crowded speculative positioning in CFTC futures markets (COT report analysis) to find contrarian setups using Jason…
Complete, populate and fill out 3-statement financial model templates (Income Statement, Balance Sheet, Cash Flow Statement) .…
Complete, populate and fill out 3-statement financial model templates (Income Statement, Balance Sheet, Cash Flow Statement) .…