agentsclimarketplace

Hurst exponent dynamics crisis prediction

Skill mahmoud20138/Tradecraft/plugins/tradecraft/skills/hurst-exponent-dynamics-crisis-prediction

102 Claude Code skills across 7 categories -- trading strategies, Azure, VSCode extensions, AI prompts, and custom automation skills

Install
npx -y skills add mahmoud20138/Tradecraft --skill hurst-exponent-dynamics-crisis-prediction

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 7 stars7 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Mark Vogel's Oxford ISF Conference research on rolling-window Hurst exponent dynamics of wavelet-denoised S&P 500 returns (2000-2020). Covers the chaos analysis framework, cascadic wavelet denoising, recurrence quantification analysis, multifractal DFA spectra, rolling-window bootstrapping, momentum crash prediction via fractal-trend-to-mean-reversion regime shifts, and continuous wavelet transform heatmaps for crisis detection. Contradicts Mandelbrot's long-memory interpretation -- shows H>0.5 indicates fractal trends not long memory. Source: VoglData, 42nd International Symposium on Forecasting, Oxford (2022). Use this skill for "hurst exponent dynamics", "rolling window hurst", "fractal trends", "wavelet denoised returns", "chaos analysis framework", "recurrence quantification", "multifractal DFA", "momentum crash prediction", "financial crisis prediction hurst", "efficient market hypothesis violation", "nonlinear dynamics finance", "power law returns", "fractal brownian motion forecast", "cascadic wavelet filter", "poincare section attractor", "multi-resolution analysis trading", "hurst rolling window bootstrapping", "mean reversion regime shift", "stochastic vs chaotic dynamics". Works with market-regime-classifier, statistics-timeseries, fast-fourier-transform, kalman-filter, capitulation-mean-reversion, and trading-brain.

SKILL.md

18.7 KB, as published. Nobody here has run it

Skill: Hurst Exponent Dynamics & Financial Crisis Prediction | Domain: trading/quantitative-analysis | Category: Nonlinear Dynamics | Level: expert Tags: hurst-exponent, chaos-theory, wavelet-analysis, multifractal, crisis-prediction, momentum-crash

Hurst Exponent Dynamics & Financial Crisis Prediction

Source: Mark Vogel (VoglData) -- 42nd International Symposium on Forecasting, Oxford University, July 11, 2022. Academic research on Hurst exponent dynamics of cascadic wavelet filtered S&P 500 logarithmic returns (2000-2020). ~200,000 papers sampled quantitatively to extract state of the art across nonlinear dynamics, chaos theory, quantitative finance, and KF theory.


Core Finding: Fractal Trends, Not Long Memory

Mandelbrot's classical interpretation states that H > 0.5 reveals long memory in the data. This research contradicts that conception:

  • When fractal trends are removed from financial market data, H drops to 0.5
  • H > 0.5 therefore indicates fractal trending characteristics, not long memory
  • These fractal trends cause the momentum effect (alpha generation, outperformance)
  • This is a direct contradiction of the Efficient Market Hypothesis

Hurst Exponent Interpretation (Revised)

H ValueClassical (Mandelbrot)Revised (Vogel et al.)
H = 0.5Random walk / stochasticStochastic / martingale (EMH valid)
H > 0.5Long memory / persistenceFractal trending (momentum)
H < 0.5Anti-persistence / mean reversionMean-reverting process

Key implication: All rolling-window Hurst exponents tested were significantly different from 0.5 (bootstrapped with 50,000 iterations), meaning the EMH is systematically violated.


The Chaos Analysis Framework (4 Steps)

Designed for non-stationary financial data. Each step addresses a specific analytical need.

Step 1: Prerequisites & Standard Tests

  • Noise reduction: Cascadic wavelet filtering (denoising) -- critical because noise destroys any nonlinear analysis
  • Stationarity tests: Determines which parts of the framework are applicable
  • Distribution tests: Gaussianity checks
  • Nonlinearity tests: Confirms nonlinear structure exists
  • Correlation structure analysis and entropy measurement
  • Significance tests where distributional theory permits

Step 2: Recurrence Quantification Analysis (RQA)

  • Graphically and quantitatively determines the empirical data generating process
  • Recurrence plots reveal recurrence characteristics of the data
  • Used to compare against surrogate data and known chaotic systems
  • Quantified measures determine whether dynamics are deterministic-chaotic vs stochastic

Step 3: Multi-Resolution Analysis (MRA)

  • Continuous wavelet transformation (Shannon wavelet, 1024 scales)
  • Identifies exploitable frequency components for trading systems
  • Medium/long-term Hurst series show exploitable frequency information
  • Short-term (H-100) series show only residual noise in detail coefficients

Step 4: Multifractal Detrended Fluctuation Analysis (MF-DFA)

  • Computes multifractal spectra, scaling laws, and power law distributions
  • Local min/max exponents confirm fractal trending (H > 0.5)
  • Complementary cumulative distribution functions reveal fat-tailed power laws
  • Two sources of multifractality: (a) fat-tail distributions, (b) nonlinear temporal correlations

Rolling Window Hurst Exponent Methodology

Window Configuration

Original data: daily S&P 500 log returns (denoised via cascadic wavelet filter)
Step size:     1 (overlapping, maximum data points)
Window sizes:  100, 1000, 2500 days
Significance:  50,000-step bootstrapping (all significantly != 0.5)

What Each Window Captures

WindowCapturesCharacteristics
H-100Long-term developmentShort memory (exponentially decaying autocorrelation)
H-1000Medium-term structureTrue long memory (slow-decaying autocorrelation)
H-2500Short-term developmentTrue long memory (slow-decaying autocorrelation)

Empirical Data Generating Process

All three series are autoregressive-like processes with stacked properties:

  • Non-Gaussian distribution
  • No hidden sub-dynamics (wavelet detail coefficients show only white noise)
  • Partially exploitable frequency information (H-1000, H-2500)
  • High autocorrelation functions
  • Multifractal spectra with fat-tailed power laws

Crisis Detection: The CWT Heatmap Method

This is the novel contribution -- not found in prior literature.

Procedure

  1. Shift rolling window through denoised S&P 500 return series
  2. For each window, compute continuous wavelet transform (CWT) spectrum
  3. For each CWT coefficient matrix, calculate mean vector across scales
  4. Stack rolling-window mean vectors into a heatmap

What the Heatmap Reveals

The heatmap shows average frequency-per-scale behavior of S&P 500 returns over time. Cross-referencing with Hurst exponent behavior:

CRISIS SIGNATURE (e.g., Subprime Crisis):
1. Hurst exponent rises sharply (strong fractal trending / momentum)
2. CWT frequency information becomes strongly positive and significant
3. SUDDEN DROP: Hurst falls into mean-reversion territory (H < 0.5)
4. CWT frequencies drop back to negative
=> This transition IS the momentum crash

Window Size Effects on Resolution

WindowCrisis ResolutionTrade-off
H-100Highest resolution, clearest crisis signalsMore noise
H-1000Visible interconnection on frequency levelSmearing effects
H-2500Long-term regime shifts visibleSignificant loss of resolution

Chaos-Hurst-Momentum Connection

The theoretical chain linking chaos theory to tradeable momentum:

Dissipative chaotic system (phase space deflates)
    |
    v
Strange attractor (data lives on this structure)
    |
    v
Poincare section of attractor = fractal set
    |
    v
Fractal set requires scaling laws (power laws)
    |
    v
Scaling exponents extractable via MF-DFA
    |
    v
Fractal trends measurable by Hurst exponent
    |
    v
Fractal trends CAUSE momentum effect
    |
    v
Momentum crash = transition from H > 0.5 to H < 0.5

Conclusion: Hurst exponent dynamics are non-chaotic even though they stem from a chaotic system. They can directly evaluate EMH validity and detect regime transitions.


Forecasting Results (What Does NOT Work)

The research tested multiple forecasting approaches on Hurst exponent series:

MethodResultNotes
Fractional Brownian MotionOnly acceptable for H-100Moving-average-like, within error metrics
Standard AR/ARMA modelsFailedCannot reproduce complex stochastic DGP
LSTM deep learningFailedDislikes sharp, frequently-switching data
MLP neural networksFailedSame sensitivity to switching dynamics
Wavelet neural networksFailedReplacing activation with wavelet function did not help
Multifractal Brownian MotionFailedStacked errors from Hurst estimation + chaotic error growth

Root causes of failure:

  1. Error propagation: estimation errors in step 1 compound in step 2
  2. Exponential error growth inherent to chaotic systems
  3. Neural networks (especially LSTM/MLP) struggle with sharp, frequently switching regimes
  4. Standard stochastic processes lack the complexity to model the true DGP

Python Implementation

import numpy as np
import pandas as pd
from typing import Tuple, List, Optional

def hurst_rs(series: np.ndarray) -> float:
    """
    Rescaled Range (R/S) Hurst exponent estimator.
    H > 0.5: fractal trending (momentum)
    H = 0.5: random walk (EMH valid)
    H < 0.5: mean-reverting
    """
    n = len(series)
    if n < 20:
        return 0.5
    max_k = int(np.floor(n / 4))
    sizes = []
    rs_values = []
    for k in range(10, max_k + 1):
        num_segments = n // k
        rs_seg = []
        for i in range(num_segments):
            segment = series[i * k:(i + 1) * k]
            mean_seg = np.mean(segment)
            deviate = np.cumsum(segment - mean_seg)
            r = np.max(deviate) - np.min(deviate)
            s = np.std(segment, ddof=1)
            if s > 0:
                rs_seg.append(r / s)
        if rs_seg:
            sizes.append(k)
            rs_values.append(np.mean(rs_seg))
    if len(sizes) < 2:
        return 0.5
    log_sizes = np.log(sizes)
    log_rs = np.log(rs_values)
    coeffs = np.polyfit(log_sizes, log_rs, 1)
    return coeffs[0]


def rolling_hurst(returns: np.ndarray, window: int = 100, step: int = 1) -> np.ndarray:
    """
    Compute rolling-window Hurst exponents (step=1 for maximum resolution).
    Windows: 100 (long-term dev), 1000 (medium), 2500 (short-term dev).
    """
    n = len(returns)
    indices = range(window, n + 1, step)
    h_values = np.full(len(indices), np.nan)
    for i, end in enumerate(indices):
        segment = returns[end - window:end]
        h_values[i] = hurst_rs(segment)
    return h_values


def bootstrap_hurst_significance(
    returns: np.ndarray,
    window: int = 100,
    n_bootstrap: int = 50000,
    alpha: float = 0.05
) -> dict:
    """
    Bootstrap test: is observed Hurst significantly different from 0.5?
    Generates n_bootstrap shuffled surrogates (destroying temporal structure)
    and compares observed H to the null distribution.
    """
    observed_h = hurst_rs(returns[:window])
    null_dist = np.zeros(n_bootstrap)
    for b in range(n_bootstrap):
        shuffled = np.random.permutation(returns[:window])
        null_dist[b] = hurst_rs(shuffled)
    p_value = np.mean(np.abs(null_dist - 0.5) >= np.abs(observed_h - 0.5))
    ci_lower = np.percentile(null_dist, 100 * alpha / 2)
    ci_upper = np.percentile(null_dist, 100 * (1 - alpha / 2))
    return {
        "observed_h": round(observed_h, 4),
        "p_value": round(p_value, 6),
        "significant": p_value < alpha,
        "null_ci": (round(ci_lower, 4), round(ci_upper, 4)),
        "interpretation": (
            "FRACTAL TRENDING (momentum)" if observed_h > ci_upper else
            "MEAN REVERTING" if observed_h < ci_lower else
            "STOCHASTIC (EMH consistent)"
        )
    }


def detect_regime_shift(
    h_series: np.ndarray,
    threshold_high: float = 0.6,
    threshold_low: float = 0.45,
    lookback: int = 5
) -> dict:
    """
    Detect Hurst regime transitions that precede momentum crashes / crises.
    Pattern: H rises sharply above threshold_high, then drops below threshold_low.
    """
    if len(h_series) < lookback + 1:
        return {"regime": "INSUFFICIENT_DATA", "crisis_warning": False}
    current_h = h_series[-1]
    recent_max = np.max(h_series[-lookback - 1:-1])
    recent_min = np.min(h_series[-lookback - 1:-1])
    recent_slope = (h_series[-1] - h_series[-lookback]) / lookback
    # Crisis signature: was trending (high H), now dropping toward mean reversion
    crisis_warning = (recent_max > threshold_high and
                      current_h < recent_max - 0.1 and
                      recent_slope < -0.01)
    if current_h > threshold_high:
        regime = "STRONG_FRACTAL_TREND"
    elif current_h > 0.5:
        regime = "WEAK_TREND"
    elif current_h > threshold_low:
        regime = "STOCHASTIC"
    else:
        regime = "MEAN_REVERTING"
    return {
        "regime": regime,
        "current_h": round(current_h, 4),
        "recent_max_h": round(recent_max, 4),
        "h_slope": round(recent_slope, 6),
        "crisis_warning": crisis_warning,
        "interpretation": (
            "MOMENTUM CRASH WARNING: H dropping from trend to mean-reversion"
            if crisis_warning else
            f"Current regime: {regime}"
        )
    }


def wavelet_denoise(series: np.ndarray, wavelet: str = 'db9', level: int = 4) -> np.ndarray:
    """
    Cascadic wavelet denoising (prerequisite for valid nonlinear analysis).
    Uses Daubechies-9 wavelet as in the original research.
    Requires pywt: pip install PyWavelets
    """
    import pywt
    coeffs = pywt.wavedec(series, wavelet, level=level)
    # Threshold detail coefficients (universal threshold)
    sigma = np.median(np.abs(coeffs[-1])) / 0.6745
    threshold = sigma * np.sqrt(2 * np.log(len(series)))
    denoised_coeffs = [coeffs[0]]  # Keep approximation
    for c in coeffs[1:]:
        denoised_coeffs.append(pywt.threshold(c, threshold, mode='soft'))
    return pywt.waverec(denoised_coeffs, wavelet)[:len(series)]


def full_hurst_crisis_pipeline(
    prices: pd.Series,
    windows: List[int] = [100, 1000, 2500],
    denoise: bool = True
) -> dict:
    """
    Complete pipeline: prices -> log returns -> denoise -> rolling Hurst -> regime detection.
    """
    log_returns = np.diff(np.log(prices.values))
    if denoise:
        log_returns = wavelet_denoise(log_returns)
    results = {}
    for w in windows:
        if len(log_returns) < w:
            continue
        h_series = rolling_hurst(log_returns, window=w)
        regime = detect_regime_shift(h_series)
        results[f"H-{w}"] = {
            "hurst_series": h_series,
            "latest_h": round(h_series[-1], 4) if len(h_series) > 0 else None,
            "mean_h": round(np.nanmean(h_series), 4),
            "std_h": round(np.nanstd(h_series), 4),
            "regime": regime
        }
    return results

Trading Applications

1. Momentum Crash Early Warning

Monitor rolling Hurst exponents across multiple windows. When H-100 shows a sharp drop from strong trending (H > 0.65) toward mean reversion (H < 0.50), this signals an impending momentum crash -- reduce trend-following exposure immediately.

2. Regime-Adaptive Strategy Selection

H > 0.6  =>  Deploy trend-following / momentum strategies
H ~ 0.5  =>  Market is random-walk-like; reduce exposure or use delta-neutral
H < 0.45 =>  Deploy mean-reversion strategies (Bollinger, RSI extremes)

3. EMH Validity Check Before Strategy Deployment

Before deploying any strategy, check whether the current Hurst regime supports the strategy type. Trend-following in a mean-reverting regime (or vice versa) will produce systematic losses.

4. Crisis Period Frequency Exploitation

CWT heatmaps during crisis transitions show exploitable frequency components. Medium/long-window Hurst series (H-1000, H-2500) contain frequency information that can inform systematic entry/exit timing.


Related Skills

SkillIntegration
market-regime-classifierUse Hurst regimes as input features for ML regime classification
statistics-timeseriesFoundation for stationarity tests, autocorrelation analysis
fast-fourier-transformComplement CWT frequency analysis with FFT for exploitable cycles
kalman-filterOnline Hurst estimation with state-space models
capitulation-mean-reversionTrigger capitulation scans when Hurst drops from trend to mean-reversion
momentum-roc-strategyValidate momentum signals against Hurst fractal-trend confirmation
market-regime-classifierCross-validate regime shifts from Hurst with other regime detectors

Quick Reference Card

HURST EXPONENT DYNAMICS -- CRISIS PREDICTION FRAMEWORK
=======================================================
SOURCE: Vogel, Oxford ISF 2022 | DATA: S&P 500 log returns 2000-2020

KEY FINDING: H > 0.5 = fractal trends (NOT long memory as Mandelbrot claimed)

PIPELINE:
  Raw prices -> Log returns -> Wavelet denoise (db9) -> Rolling Hurst (100/1000/2500)
                                                      -> Bootstrap significance (50k)
                                                      -> CWT heatmap for crisis detection

REGIME MAP:
  H > 0.60  STRONG FRACTAL TREND   => Momentum strategies, ride trends
  H ~ 0.50  STOCHASTIC             => EMH-like, reduce exposure
  H < 0.45  MEAN REVERTING         => Mean-reversion strategies

CRISIS SIGNATURE:
  1. H rises sharply (strong momentum phase)
  2. H DROPS suddenly toward 0.5 or below
  3. CWT frequencies flip from positive to negative
  => MOMENTUM CRASH / FINANCIAL CRISIS IN PROGRESS

WHAT DOES NOT WORK FOR FORECASTING H:
  - LSTM / MLP / wavelet neural networks (hate switching regimes)
  - Standard ARMA (too simple for the DGP)
  - Multifractal Brownian Motion (stacked error propagation)
  - Only fractional Brownian Motion on H-100 gives acceptable results

CHAOS-TO-MOMENTUM CHAIN:
  Chaotic system -> Strange attractor -> Poincare section (fractal)
  -> Scaling/power laws -> MF-DFA exponents -> Hurst measures fractal trends
  -> Fractal trends = momentum effect -> H regime shift = momentum crash

BOOTSTRAPPING:
  50,000 shuffled surrogates | All windows significantly != 0.5
  => EMH systematically violated across 20 years of S&P 500 data

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.