Analyze historical downtrend durations and generate interactive HTML histograms showing typical correction lengths by sector and market cap.
Downtrend Duration Analyzer
Overview
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.
When to Use
Trader asks about typical correction lengths for a sector or market cap tier
User wants to understand historical drawdown recovery times
8 files · 58 KB5 KB
Install
It’s free, and every skill you add syncs into every AI tool on your computer, instantly.
# 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 Insights1. 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
HTML Visualization
Interactive histogram saved to reports/downtrend_histogram_YYYY-MM-DD.html with:
Plotly.js-based interactive charts
Sector and market cap dropdown filters
Duration distribution with bin controls
Percentile markers (P25, P50, P75, P90)
Reports are saved to reports/ with filenames:
downtrend_analysis_YYYY-MM-DD_HHMMSS.json
downtrend_analysis_YYYY-MM-DD_HHMMSS.md
downtrend_histogram_YYYY-MM-DD_HHMMSS.html
Resources
scripts/analyze_downtrends.py -- Main analysis script for fetching data and computing downtrend durations
scripts/generate_histogram_html.py -- HTML visualization generator with interactive histograms
references/downtrend_methodology.md -- Peak/trough detection algorithms and market cap tier definitions
Key Principles
Statistical Rigor: Use robust peak/trough detection to avoid noise-induced false signals
Segmentation Matters: Always analyze by sector and market cap; averages hide important differences
Realistic Expectations: Use percentiles (not just means) to understand the full distribution of outcomes