downtrend-duration-analyzer
Analyze historical downtrend durations and generate interactive HTML histograms showing typical correction lengths by sector and market cap.
Skill by mphinance
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/mphinance-downtrend-duration-analyzer
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: frontend
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
- Runs as
- Python package
Network hosts it talks to 3
cdn.plot.ly· found in codecodeload.github.com· found in install commandfinancialmodelingprep.com· found in code
Files it touches
~/.claude/skills/downtrend-duration-analyzer
What's inside
- Skill name
downtrend-duration-analyzer- Description
- Analyze historical downtrend durations and generate interactive HTML histograms showing typical correction lengths by sector and market cap.
- License
- MIT
- Instructions
- 173 lines in SKILL.md · view on GitHub
Before installing
- Ships executable scripts
Files (8)
- README.md
- SKILL.md
- downtrend_methodology.md · references/
- analyze_downtrends.py · scripts/
- generate_histogram_html.py · scripts/
- conftest.py · scripts/tests/
- test_analyze_downtrends.py · scripts/tests/
- test_generate_histogram_html.py · scripts/tests/
SKILL.md (first lines)
# 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
- Building mean reversion or pullback strategies that need realistic holding period estimates
- Comparing correction behavior across different market segments
- Setting stop-loss timeouts or position holding period limits
## Prerequisites
- Python 3.9+
- FMP API key (set `FMP_API_KEY` environment variable or use `--api-key`)
- Required packages: `requests`, `pandas`, `numpy` (standard data analysis stack)
## Workflow
### Step 1: Fetch Historical Price Data
Run the analysis script to fetch OHLC data for a universe of stocks and identify downtrend periods.
```bash
python3 skills/downtrend-duration-analyzer/scripts/analyze_downtrends.py \
--sector "Technology" \
--lookback-years 5 \
--output-dir reports/
```
### Step 2: Analyze Downtrend Durations
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)
### Step 3: Generate Interactive HTML Visualization
```bash
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:
- Histogram of downtrend durations
- Filters for sector and market cap
- Hover tooltips with percentile information
- Summary statistics table
### Step 4: Review Distribution Insights
Load the generated markdown report to interpret the findings:
- **Short corrections (5-15 days)**: Typical pullbacks within uptrends
- **Medium corrections (15-40 days)**: Standard sector rotations
- **Extended corrections (40+ days)**: Trend changes or bear markets
## Output Format
### JSON Report
```json
{
"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
}
]
}
```
### Markdown Report
```markdown
# Downtrend Duration Analysis
**Date**: 2026-03-28
**Lookback**: 5 years
**Sector**: TechnologyFrom mphinance/alpha-skills, MIT.
More from mphinance/alpha-skills
- 0.650score
mph-pine
mphinance
Build TradingView Pine Script v6 indicators in Michael's house style.
SkillAFreshness: A★ 29Claude Code +9 - 0.615score
dividend-growth-pullback-screener
mphinance
Use this skill to find high-quality dividend growth stocks (12%+ annual dividend growth, 1.5%+ yield) that are experiencing temporary pullbacks, identified by…
SkillBFreshness: B★ 29Claude Code +9 - 0.615score
breakout-trade-planner
mphinance
Generate Minervini-style breakout trade plans from VCP screener output with worst-case risk calculation, portfolio heat management, and Alpaca-compatible…
SkillBFreshness: B★ 29Claude Code +9 - 0.615score
edge-candidate-agent
mphinance
Generate and prioritize US equity long-side edge research tickets from EOD observations, then export pipeline-ready candidate specs for…
SkillBFreshness: B★ 29Claude Code +9 - 0.615score
edge-strategy-reviewer
mphinance
Critically review strategy drafts from edge-strategy-designer for edge plausibility, overfitting risk, sample size adequacy, and execution realism.
SkillBFreshness: B★ 29Claude Code +9 - 0.615score
coil-scan
mphinance
Daily scanner that finds stocks sitting in the "bottom of the coil" using a dual-timeframe Williams %R Trend Exhaustion indicator, then flags the ones that…
SkillBFreshness: B★ 29Claude Code +9 - 0.615score
economic-calendar-fetcher
mphinance
Fetch upcoming economic events and data releases using FMP API.
SkillBFreshness: B★ 29Claude Code +9 - 0.615score
broker-mcp-selector
mphinance
Pick a broker MCP server your AI agent can actually execute trades through, and wire it up safely.
SkillBFreshness: B★ 29Claude Code +9 - 0.615score
earnings-trade-analyzer
mphinance
Analyze recent post-earnings stocks using a 5-factor scoring system (Gap Size, Pre-Earnings Trend, Volume Trend, MA200 Position, MA50 Position).
SkillBFreshness: B★ 29Claude Code +9 - 0.615score
edge-pipeline-orchestrator
mphinance
Orchestrate the full edge research pipeline from candidate detection through strategy design, review, revision, and export.
SkillBFreshness: B★ 29Claude Code +9 - 0.612score
edge-concept-synthesizer
mphinance
Abstract detector tickets and hints into reusable edge concepts with thesis, invalidation signals, and strategy playbooks before strategy design/export.
SkillBFreshness: B★ 29Claude Code +9 - 0.612score
edge-hint-extractor
mphinance
Extract edge hints from daily market observations and news reactions, with optional LLM ideation, and output canonical hints.yaml for downstream concept…
SkillBFreshness: B★ 29Claude Code +9
Signals
- Stars
- 29
- Forks
- 6
- Open issues
- 0
- Last commit (this folder)
- Aug 28, 2026 (2 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/mphinance/alpha-skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from mphinance
- 0.650score
mph-pine
mphinance
Build TradingView Pine Script v6 indicators in Michael's house style.
SkillAFreshness: A★ 29Claude Code +9 - 0.615score
broker-mcp-selector
mphinance
Pick a broker MCP server your AI agent can actually execute trades through, and wire it up safely.
SkillBFreshness: B★ 29Claude Code +9 - 0.615score
breakout-trade-planner
mphinance
Generate Minervini-style breakout trade plans from VCP screener output with worst-case risk calculation, portfolio heat management, and Alpaca-compatible…
SkillBFreshness: B★ 29Claude Code +9 - 0.615score
earnings-trade-analyzer
mphinance
Analyze recent post-earnings stocks using a 5-factor scoring system (Gap Size, Pre-Earnings Trend, Volume Trend, MA200 Position, MA50 Position).
SkillBFreshness: B★ 29Claude Code +9 - 0.615score
coil-scan
mphinance
Daily scanner that finds stocks sitting in the "bottom of the coil" using a dual-timeframe Williams %R Trend Exhaustion indicator, then flags the ones that…
SkillBFreshness: B★ 29Claude Code +9 - 0.615score
dividend-growth-pullback-screener
mphinance
Use this skill to find high-quality dividend growth stocks (12%+ annual dividend growth, 1.5%+ yield) that are experiencing temporary pullbacks, identified by…
SkillBFreshness: B★ 29Claude Code +9
Cite this page
downtrend-duration-analyzer skill. Agent Mart. https://agentmart.dev/skills/mphinance-downtrend-duration-analyzer (last updated 2026-10-24)