Lab

Lab — cross-asset structure

Cross-asset rolling correlation cube

A 3-tensor C[a, b, w] of rolling pairwise correlations across an asset universe — the substrate for regime-shift detection.

The mathematics

Let R ∈ ℝK×T be a multi-asset return matrix: K assets, T bars. For a fixed window length L, define for every window-end index w ∈ {L, L+1, …, T}

Standardize each row of R(w) within the window (subtract mean, divide by sample std) to get Z(w). The sample correlation matrix at window w is

The correlation cube is the 3-tensor

Useful invariants

Compute summary scalars at each window slice and track them as time series.

  • Mean off-diagonal correlation — single scalar regime indicator.
  • Leading eigenvalue — captures the strength of the largest common factor.
  • Effective rank — the entropy of the normalised spectrum, smoothly between 1 (one factor) and K (full rank).

Crisis regimes are characterised by simultaneous elevation of mean off-diagonal correlation and collapse of effective rank to a value near 1. The Forbes–Rigobon (2002) volatility-bias correction matters here: an apparent rise in correlation during a high-volatility regime is partly mechanical (variance enters both the numerator and denominator). The library reports both raw and bias-corrected estimates.

Window length tradeoff

At window length L the standard error of any sample correlation is approximately (1 − ρ²)/√L. Short windows (L = 20) react quickly but are noisy; long windows (L = 250) are stable but lag regime shifts by L/2. For 30-minute crypto data we typically run L = 60 (a calendar week of bars) and report the time series of mean off-diagonal as the primary regime indicator.

Worked example

Generate a 6-asset universe (BTC, ETH, SOL, XAU, EUR, JPY), T = 600 bars, with a regime switch at t = T/2. In the first half each asset loads on one of two block factors with intra-block correlation 0.36. In the second half all assets load on a single global factor with intensity τ ∈ [0, 0.95]; this is the crisis regime.

Theoretical mean off-diagonal correlations:

  • Pre-crisis: ≈ 0.36 within block, ≈ 0 cross-block, mean off-diag ≈ 0.36 · (2 · 3) / 15 = 0.144.
  • Post-crisis with τ = 0.7: ≈ 0.7 across all pairs.

The demo below renders this experiment as a heatmap of one window slice and the time series of mean off-diagonal correlation across all windows. Watch the off-diagonal lift sharply at the regime switch — that’s the regime indicator the production pipeline triggers on.

Demo — Cross-asset rolling correlation cube

6 assets, T=600 bars. Block-correlated regime in the first half, single-factor crisis regime in the second. Rolling W-window correlation matrices form the cube.

W (window length)60
crisis intensity0.70
window position0
seed=2
windows
540
window end (t)
60
mean off-diag
0.136
cube shape
6×6×540
Correlation matrix at window 0 (end t=60)
BTCETHSOLXAUEURJPYBTCETHSOLXAUEURJPY1.000.450.360.090.060.160.451.000.27-0.110.11-0.090.360.271.00-0.10-0.24-0.090.09-0.11-0.101.000.330.450.060.11-0.240.331.000.400.16-0.09-0.090.450.401.00
Mean off-diagonal correlation across rolling windows
-1.0-0.50.00.51.0window index (time)

Figures

Full-sample 12-asset cross-asset correlation heatmap
Fig. 1A single full-sample slice of the cube — the K × K Pearson correlation matrix between daily aggregate strategy returns across the 12 assets with daily P&L records. Annotated invariants: mean off-diagonal correlation ρ̄, leading eigenvalue λ₁, and effective rank r_eff = exp(−Σ pᵢ log pᵢ) of the normalised spectrum.
Three time-slice heatmaps and the rolling cube collapse
Fig. 2Top: three time-slice correlation matrices (early / middle / late) from the same K-asset universe, computed on rolling 60-day windows. Bottom: the time series of the mean off-diagonal ρ̄ (amber) and effective rank r_eff (teal) across all rolling windows. Episodes of cube collapse — ρ̄ rising and r_eff falling — are the regime indicator the production pipeline triggers on.

Why this matters for systematic strategies

A diversified systematic portfolio implicitly bets that the cross-asset correlation matrix is well-conditioned — that there are several effective directions of risk to spread allocation across. When the correlation cube collapses to a single direction, the diversification disappears mechanically. The cube exposes this collapse as soon as it starts, before P&L confirms it.

Operationally we feed the cube into M/04: the correlation matrix is the parameter of the Gaussian copula whose χ is identically zero. When the empirical χ on the same data is meaningfully positive, the Gaussian-copula assumption underlying the correlation matrix is broken, and any risk model that uses only correlations is mis-specified.

Reproducibility

DaruFinance / strategy-corrcube

Python — open source reference implementation

Minimal invocation

import numpy as np
from strategy_corrcube import rolling_corr_cube, mean_offdiag

# R: K x T multi-asset return matrix (rows = assets, cols = time)
cube = rolling_corr_cube(R, window=60)   # shape: (K, K, T - window + 1)
mean_off = mean_offdiag(cube)             # shape: (T - window + 1,)
# Track regime shifts:
crisis_mask = mean_off > 0.6

References

  1. [1]Engle, R. F. (2002). Dynamic conditional correlation: A simple class of multivariate GARCH models. Journal of Business & Economic Statistics 20(3), 339–350.
  2. [2]Pelletier, D. (2006). Regime switching for dynamic correlations. Journal of Econometrics 131, 445–473.
  3. [3]Forbes, K. J. & Rigobon, R. (2002). No contagion, only interdependence: measuring stock market comovements. Journal of Finance 57(5), 2223–2261.