Quant Trader Lab
MF-DFA / Scaling

Multifractal Spectrum

Open case study
Type:  Quant case study
Question:  How does risk scale across horizons?
Stack:  MF-DFA, H(q), tau(q), Legendre spectrum
01 / Problem

Markets do not scale with one clean rule.

Classical market models often compress a price series into one volatility number, one Hurst exponent, or one regime assumption. That is useful for a first approximation, but it misses a key empirical feature of financial data: calm fluctuations and stress moves do not behave as the same object observed at different sizes.

The multifractal spectrum addresses that problem by measuring how local roughness changes across time scales and across moment orders. Instead of asking only whether a market trends, mean-reverts, or becomes volatile, it asks how different fluctuation intensities scale through time.

Financial hypothesis

A market is not a homogeneous process. It is a superposition of microstructure noise, ordinary volatility, clustered volatility and rare stress bursts, each with its own scaling behavior.

Case objective

Estimate the spectrum width, curvature and asymmetry to quantify market complexity, regime fragility and the gap between normal fluctuations and extreme events.

02 / Method

MF-DFA turns returns into scale diagnostics.

The workflow begins with returns r(t). After removing the mean, the series is integrated into a profile Y(t). This profile is split into windows of length s, each window is locally detrended, and the residual variance is measured. Repeating the process over many window sizes gives a family of fluctuation measurements.

Fq(s) ~ s^h(q)

The parameter q controls which fluctuations dominate the estimate. Positive q emphasizes large deviations and stress behavior; negative q emphasizes small fluctuations and quiet-market texture. If h(q) changes with q, the market is multifractal.

H(q)

Generalized Hurst exponent.

Measures how fluctuations scale for each moment q. A constant h(q) indicates monofractality; a moving h(q) indicates heterogeneous market dynamics.

tau(q)

Mass exponent.

Defined as tau(q) = qh(q) - 1 for a one-dimensional time series. Its curvature summarizes how scaling mass redistributes across moments.

f(alpha)

Singularity spectrum.

Obtained through a Legendre transform. It describes the distribution of local scaling exponents alpha across the process.

Delta alpha

Market complexity proxy.

The spectrum width measures the distance between quiet and violent scaling regimes. Wider usually means stronger intermittency and clustering.

03 / Demonstration

The spectrum is a Legendre map of scaling behavior.

Once h(q) has been estimated from the slopes of log Fq(s) against log s, the mass exponent is computed as tau(q) = qh(q) - 1. The local singularity strength is the derivative alpha = d tau(q) / dq. The final spectrum is f(alpha) = q alpha - tau(q).

This transformation changes the object being studied. We move from a time series of returns to a geometry of scaling intensities. The peak of f(alpha) identifies the dominant roughness class; the width Delta alpha measures heterogeneity; the left and right asymmetries describe whether large or small fluctuations carry more structural complexity.

In the interactive surface above, each scenario changes the shape of h(q), which then changes tau(q) and bends the f(alpha) spectrum. A monofractal case stays narrow. A clustered or stress-driven process opens the spectrum and makes the market look structurally uneven.

Mathematical chain

Profile Y(t), window scale s, detrended fluctuation Fq(s), generalized exponent h(q), mass exponent tau(q), singularity strength alpha, then Legendre spectrum f(alpha).

Trading interpretation

A widening spectrum warns that risk is becoming less homogeneous. Position sizing, volatility targeting and tail hedging should treat the market as regime-dependent rather than Gaussian and stationary.

04 / Python Core

The implementation is a slope engine plus a transform.

The Python logic mirrors the math: build the integrated profile, estimate Fq(s) across scales, regress log Fq(s) on log s to obtain h(q), then compute the Legendre spectrum. The snippet below focuses on the final deterministic layer after h(q) has been estimated.

import numpy as np

def multifractal_spectrum(q, hq):
    tau = q * hq - 1.0
    alpha = np.gradient(tau, q)
    f_alpha = q * alpha - tau
    width = alpha.max() - alpha.min()
    return tau, alpha, f_alpha, width

q = np.linspace(-5, 5, 81)
hq = 0.56 - 0.035 * q + 0.008 * q**2
tau, alpha, f_alpha, width = multifractal_spectrum(q, hq)

In a production research notebook, h(q) would come from rolling MF-DFA estimates on real returns. The resulting width, curvature and skew can then be tracked as market-state features beside realized volatility, drawdown and liquidity metrics.