Cointegration Basket
Find stationary combinations across multiple assets simultaneously
Risk
Medium
Holding Period
Days to weeks
Best For
More stable mean-reversion than two-asset pairs
How it works
Find stationary combinations across multiple assets simultaneously
Mathematical Foundation
basket = w₁·p₁ + w₂·p₂ + … + wₙ·pₙ weights w from Johansen eigenvectorSignal Generation Logic
- 1Apply the Johansen cointegration test to a group of N assets simultaneously
- 2Extract the first eigenvector from the test as the optimal basket weights
- 3Form the basket value as the weighted sum of all asset prices
- 4Calculate rolling basket mean and standard deviation over the test window
- 5Enter when basket Z-score exceeds ±2.0 — buy underweight assets, sell overweight
- 6Exit when |Z-score| < 0.5 — basket has returned to equilibrium
- 7Re-test Johansen relationship periodically; exit if cointegration breaks down
Parameters Explained
entry_zZ-score threshold for basket entry. The basket involves multiple assets so a wider threshold reduces false signals from noise.
Default
2exit_zZ-score threshold for basket exit. When the basket's weighted price returns to near its mean, all positions in the basket are closed.
Default
0.5johansen_windowRolling window for Johansen cointegration test. Determines how many bars of price history are used to estimate the cointegrating vectors.
Default
120When It Works
In markets where multiple assets share a common long-run equilibrium — for example, a basket of related currency pairs that are all tied to the same underlying economic factors. Johansen allows testing for cointegration across 3+ assets simultaneously, finding more stable relationships than pairwise testing.
When It Fails
When the cointegrating relationship among the basket members breaks down. With more assets in the basket, there are more potential failure points. Also fails during periods of global de-correlation or asset-class-level stress.
Risks & Limitations
- Managing N simultaneous positions increases operational complexity and execution risk
- Johansen eigenvectors can be unstable out-of-sample — weights can flip significantly
- Rebalancing costs are amplified with more basket constituents
- Cointegration tests assume stationarity which may not hold during structural breaks
- Short positions on some basket members may be restricted or expensive
Implementation
Uses statsmodels' Johansen cointegration test (vecm module) to find the optimal cointegrating vector. The first eigenvector corresponding to the largest eigenvalue is used as the basket weights. The basket spread is then treated identically to a 2-asset pair-trading spread.
Model parameters
Entry Z-Score
Open basket when Z ≥ 2σ
Exit Z-Score
Close when basket reverts
Johansen Window
Days for Johansen VECM test
Academic background
Academic Basis
Based on Johansen (1988), 'Statistical Analysis of Cointegration Vectors', Journal of Economic Dynamics and Control
Backtest this strategy
Run the exact model on your selected assets and date range. See trade-by-trade performance.
Backtest This →