Pro Feature. Requires a Pro or Ultra subscription. Get started at api.mathematicalcompany.com
Statistical Arbitrage
A more rigorous version of Spread Convergence. Uses OLS hedge ratio, ADF stationarity testing, and half-life filtering to identify truly cointegrated pairs.How It Works
- Collect price histories for both markets
- Compute OLS hedge ratio:
beta = cov(a,b) / var(b) - Compute residuals:
r = a - beta * b - Run ADF test on residuals (more negative = more stationary)
- Check
signal_half_life()on residuals (reject if outside bounds) - Compute z-score of current residual
- Generate entry/exit/stop signals
Rust Functions
cointegration_test
spread_zscore
StatArbConfig
Pipeline: stat_arb
StatArbResult in ctx.params["last_stat_arb"].
StatArbResult
Signal Logic
Example
ADF critical values (n > 100): 1% = -3.43, 5% = -2.862, 10% = -2.567. More negative values indicate stronger stationarity evidence.