Skip to main content
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

  1. Collect price histories for both markets
  2. Compute OLS hedge ratio: beta = cov(a,b) / var(b)
  3. Compute residuals: r = a - beta * b
  4. Run ADF test on residuals (more negative = more stationary)
  5. Check signal_half_life() on residuals (reject if outside bounds)
  6. Compute z-score of current residual
  7. Generate entry/exit/stop signals

Rust Functions

cointegration_test

spread_zscore

StatArbConfig

Pipeline: stat_arb

Stores 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.