skillfed

cointegration-analysis

Cointegration Analysis identifies when two non-stationary price series move together toward a stable equilibrium, enabling statistical arbitrage and mean-reversion trading. The skill implements Engle-Granger two-step regression, Johansen multivariate testing, and rolling window monitoring to detect relationship breakdowns. Use it to screen correlated assets, estimate hedge ratios, and validate spread mean reversion before deploying pairs strategies.

Cointegration Analysis tests asset pairs for long-run equilibrium relationships suitable for pairs trading strategies.

AI-generated summary based on this skill's SKILL.md

248 52 MIT updated by agiprolabs

Install

agiprolabs/claude-trading-skills/cointegration-analysis · repository language: Python

CLI (skillfed)coming soon
git clone https://github.com/agiprolabs/claude-trading-skills
cp -r claude-trading-skills/skills/cointegration-analysis ~/.claude/skills/cointegration-analysis

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

What cointegration testing methods does cointegration-analysis support?

Cointegration-analysis implements Engle-Granger two-step regression for pairs and Johansen multivariate testing for multiple series. Both methods detect when non-stationary price series move together toward a stable long-run equilibrium, forming the foundation for statistical arbitrage. The skill also includes ADF testing of residuals to confirm stationarity and Phillips-Ouliaris cointegration as an alternative framework for validating relationships.

How do I find cointegrated trading pairs using this skill?

Cointegration-analysis screens correlated assets by applying Engle-Granger and Johansen tests to identify pairs with stable long-run equilibrium relationships. The skill estimates hedge ratios from cointegrated relationships and validates that spreads exhibit mean reversion. Once a cointegrated pair is identified, you can monitor the spread using z-score signals to trigger entry and exit points for mean-reversion trades.

What is the difference between cointegration vs correlation?

Cointegration-analysis distinguishes cointegration from correlation: correlation measures instantaneous price movement similarity, while cointegration identifies non-stationary series that share a stable equilibrium relationship. Two assets can be highly correlated but not cointegrated, or cointegrated without high correlation. Cointegration is more reliable for pairs trading because it captures mean-reversion dynamics rather than temporary price moves.

How does rolling cointegration window analysis detect relationship breakdowns?

Cointegration-analysis monitors rolling cointegration stability by recalculating Engle-Granger or Johansen test statistics over sliding time windows. This detects hedge ratio drift and structural breaks when the long-run equilibrium relationship weakens or fails. Walk-forward backtesting with rolling windows reveals when pairs strategies lose statistical validity, helping you avoid trading spurious cointegration or relationships damaged by market regime shifts.

How do I avoid spurious cointegration and structural break pitfalls?

Cointegration-analysis mitigates spurious cointegration by validating residual stationarity through ADF testing and monitoring rolling window stability. The skill flags structural breaks where the cointegrated relationship deteriorates, preventing false signals from regime changes. Walk-forward validation ensures hedge ratios and spread mean-reversion half-life estimates remain current, reducing the risk of deploying pairs strategies on broken relationships.

Can cointegration-analysis identify crypto pairs like SOL-ETH for arbitrage?

Cointegration-analysis applies Engle-Granger and Johansen testing to any asset pair, including crypto pairs like SOL-ETH or stablecoin peg arbitrage relationships. The skill estimates hedge ratios and monitors spread mean reversion for liquid staking derivatives and other correlated crypto assets. Rolling window analysis detects when crypto pairs lose cointegration due to market volatility or protocol changes, helping you time entry and exit of statistical arbitrage positions.

SKILL.md

rendered from the published skill — quoted content, verbatim

Cointegration Analysis

Cointegration testing identifies pairs of assets that share a long-run equilibrium relationship, enabling statistical arbitrage and pairs trading strategies.

What Is Cointegration?

Two price series are cointegrated when they are individually non-stationary (random walks) but a linear combination of them is stationary (mean-reverting). Intuitively, the prices may wander apart temporarily but are pulled back to an equilibrium spread over time.

Cointegration vs Correlation
Property Correlation Cointegration
Measures Short-term co-movement Long-run equilibrium
Stationarity Requires stationary returns Works with non-stationary prices
Time horizon Can change rapidly Stable over months/years
Trading use Momentum/trend signals Mean-reversion pairs trades
Failure mode Breaks in regime changes Breaks on structural shifts

Two assets can be highly correlated but not cointegrated (e.g., two unrelated uptrends). Conversely, cointegrated

(truncated - see the full file via the links below)

Read as markdown · JSON record · Browse the source repository

File tree — 5 files
skills/cointegration-analysis/SKILL.md
skills/cointegration-analysis/references/methodology.md
skills/cointegration-analysis/references/pairs_trading.md
skills/cointegration-analysis/scripts/pairs_backtest.py
skills/cointegration-analysis/scripts/test_cointegration.py

Related skills

Tags

statistical-arbitrage mean-reversion-trading pairs-strategy spread-analysis regime-stability hedge-ratios time-series-testing market-microstructure risk-hedging