Back to Docs
T
Traderoid

Cointegration Node

Tests if time series move together in equilibrium

StatisticalCorrelationAdvanced

Overview

Cointegration tests whether two or more time series that are individually non-stationary move together in a long-term equilibrium relationship. Unlike correlation which measures linear relationships, cointegration identifies stable relationships that persist over time, enabling profitable pairs trading even when price movements are random.

Two assets can be cointegrated if they're driven by similar fundamental forces and their prices deviate from a stable equilibrium only temporarily. When one asset moves significantly from the equilibrium, the other must follow to restore balance, creating predictable mean reversion opportunities for statistical arbitrage strategies.

Formula & Calculation

Johansen Test (Standard Method)
Tests for cointegrating relationships using maximum likelihood
Compares eigenvalues of covariance matrices to identify stable relationships
Hedging Ratio
Spread = Series1 - Beta × Series2
Beta from linear regression defines the equilibrium relationship

Parameters

ParameterDefaultDescription
series1, series2RequiredTwo price series to test for cointegration
lookback252Number of observations for test
confidence95%Significance level for cointegration test

Common Use Cases

1. Pairs Trading Setup

Find cointegrated stock pairs and trade deviations from equilibrium. When spread widens, short the outperformer and long the underperformer, betting on mean reversion. This creates market-neutral exposure suitable for any market regime.

2. Statistical Arbitrage

Use cointegration as foundation for algorithmic trading. Cointegrated pairs have mathematically guaranteed reversion (unlike correlation-based pairs), enabling profitable systematic strategies with quantifiable risks.

3. Portfolio Hedging

Use cointegrated relationships to hedge positions efficiently. If you own Stock A (which is cointegrated with Index), you can hedge with Stock B (also cointegrated with Index) rather than futures, avoiding carrying costs.

4. Cross-Asset Trading

Find cointegration between different asset classes (stock-bond, commodity-currency, etc.). These relationships are more stable than correlations and less likely to break down during crises.

Advantages & Limitations

Advantages

  • Identifies stable long-term relationships
  • Enables statistical arbitrage strategies
  • More reliable than correlation
  • Creates market-neutral opportunities
  • Hedging cost reduction
!

Limitations

  • Relationships break suddenly (structural breaks)
  • Requires multiple correlated assets
  • Complex calculation and interpretation
  • Statistically expensive to test
  • Regime-dependent behavior

Tips & Best Practices

📊 Monitor Spread Half-Life

Calculate how long it takes the spread to revert halfway. Shorter half-life = faster mean reversion = better trading opportunity.

🔄 Test Regularly

Cointegration relationships can break. Retest monthly and replace pairs that lose cointegration.

⚡ Use Multiple Tests

Combine Johansen test with ADF (Augmented Dickey-Fuller) for robustness. Different methods catch different relationships.

⚠️ Watch Structural Breaks

Cointegration can break suddenly due to economic changes. Set strict stop-losses and position size accordingly.

Example Strategy: Pairs Trading

1. Find cointegrated pairs using Johansen test (min 252-day period)
2. Calculate equilibrium price using hedging ratio from regression
3. Entry: Spread = (Price A - Beta × Price B) exceeds 2 standard deviations
4. Exit: Spread reverts to mean or 2-3X standard deviation exceeded
5. Position size: Scale based on spread volatility and account risk

Related Nodes