Crypto Pair Trading: A Statistical Arbitrage Strategy
Pair trading is one of the cornerstones of algo trading strategies. The idea is simple: find two assets that move together statistically, wait for their price relationship to diverge, and bet on convergence. In crypto, BTC and ETH are the classic pair.
Testing for Cointegration
from statsmodels.tsa.stattools import coint\nscore, p_value, _ = coint(btc_prices, eth_prices)\nprint("p-value:", p_value) # p < 0.05 means cointegratedThe Spread
The spread is the residual from an OLS regression of one asset on the other. You trade the spread mean-reversion. When the z-score of the spread exceeds +2, you short the spread. When it falls below -2, you go long.
Execution Challenges
Pair trading requires simultaneous execution on both legs. Leg risk—where one side fills and the other doesn't—is a real problem in live crypto algorithmic trading. Design your automated crypto trading system to handle partial fills gracefully.