Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

downtrend-duration-analyzer

БесплатноЗапускает вложенные скриптыНе проверен

Analyze historical downtrend durations and generate interactive HTML histograms showing typical correction lengths by sector and market cap.

tradermontyот tradermonty★ 9 343 звезды на GitHub

Об этом скилле

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). The stock universe comes from the company screener, which the free FMP plan does not include (HTTP 402/403); a plan that includes it is required (see docs/en/getting-started.md#fmp-plans)
  • Required packages: requests, pandas, numpy (standard data analysis stack)

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.

Reports carry the shared top-level evaluation_coverage block (#711). A symbol is evaluated when its history has enough bars for the peak/trough windows. Empty or short histories are insufficient_history, and failures are rate_limited, plan_gated, provider_error or invalid_data. A second HTTP 429 (daily limit) or an HTTP 401/402/403 on history stops the run at that symbol, and the symbols after it are not_requested. If nothing was evaluated by then, the run exits 1 without a report. Otherwise the report is written with verdict partial. Other failures are counted and the run goes on. Read the verdict before the statistics: exit 0 means the report was written, not that every symbol was evaluated.

Workflow

Step 1: Fetch Historical Price Data

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/

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

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

{
  "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
  },
  "evaluation_coverage": {
    "schema_version": "1.0",
    "universe_size": 100,
    "evaluated": 97,
    "not_evaluated": 3,
    "not_evaluated_reasons": {"insufficient_history": 3},
    "verdict": "partial"
  },
  "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",
Полный SKILL.md на GitHub

Установить downtrend-duration-analyzer в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/downtrend_methodology.mdrequirements.txtscripts/analyze_downtrends.pyscripts/downtrend_fmp_client.pyscripts/evaluation_coverage.pyscripts/fmp_client.pyscripts/generate_histogram_html.py

FAQ

Что делает скилл downtrend-duration-analyzer?

Analyze historical downtrend durations and generate interactive HTML histograms showing typical correction lengths by sector and market cap.

Как установить скилл downtrend-duration-analyzer?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл downtrend-duration-analyzer запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить downtrend-duration-analyzer с