Quantitative Backtesting: Arbitrage Strategies with Statistical Models
Arbitrage strategies exploit price discrepancies between related assets. Statistical models quantify these relationships. Quantitative backtesting verifies the profitability and robustness of such strategies.
Strategy Overview: Statistical Arbitrage (Pairs Trading)
This strategy involves trading two historically correlated assets. When their price spread deviates significantly, we buy the underperforming asset and sell the outperforming one. We target highly correlated equity pairs (e.g., XOM/CVX, KO/PEP) or ETF pairs (e.g., SPY/IVV).
Setup and Statistical Model
We use a Cointegration test (Engle-Granger) to confirm a long-term stable relationship between the two assets. If cointegrated, we model the spread using an Ordinary Least Squares (OLS) regression. The spread is defined as Asset1 - (Hedge Ratio * Asset2). The Hedge Ratio is the slope of the OLS regression. We calculate the Z-score of this spread over a 60-period lookback. We use daily data for analysis.*
Entry Rules
Short Spread (Long Asset2, Short Asset1)
- Z-score of the spread crosses above +2 standard deviations. This indicates the spread is overextended to the upside.
- The 60-period moving average of the Z-score is also above 0. This confirms the recent trend in the spread.
- Enter at market open on the next trading day. This assumes overnight processing of signals.
Long Spread (Long Asset1, Short Asset2)
- Z-score of the spread crosses below -2 standard deviations. This indicates the spread is overextended to the downside.
- The 60-period moving average of the Z-score is also below 0. This confirms the recent trend in the spread.
- Enter at market open on the next trading day. This assumes overnight processing of signals.
Exit Rules
Take Profit
- Z-score of the spread crosses back to 0. This indicates mean reversion is complete.
- Alternatively, exit after a fixed profit target of 1.5 ATR of the spread. ATR is calculated over 20 periods.
- Partial exit: Close 50% of the position when the Z-score crosses 0.5 standard deviations from the entry point.
Stop Loss
- Z-score of the spread crosses above +3.5 (for short spread) or below -3.5 (for long spread) standard deviations. This indicates a breakdown in the statistical relationship.
- Alternatively, use a fixed monetary stop loss of 0.75% of account equity. This provides a hard capital protection.
- Time-based stop: Close the trade if it remains open for 10 trading days without reaching the take profit or Z-score stop loss. This prevents capital being tied up in non-performing trades.
Risk Management Parameters
We risk 0.5% of total account equity per trade. Maximum open trades simultaneously: 5. This diversifies risk across multiple pairs. Account size: $1,000,000. Risk per trade: $5,000. Position sizing calculates the required number of shares for each leg based on the hedge ratio and the dollar amount of risk. For example, if the hedge ratio is 0.8, and we risk $5,000, the dollar value of the long leg might be $25,000, and the short leg $20,000. This requires precise calculations.
Backtesting Methodology
Data Sourcing
Obtain high-frequency historical data for at least 20 years. Ensure data includes dividends and corporate actions for equities. Use point-in-time data to avoid look-ahead bias. Verify data synchronization for both assets in the pair.
Backtesting Framework
Develop a custom backtesting engine in Python using libraries like zipline or backtrader. Implement the Cointegration test and OLS regression dynamically. Re-calculate the hedge ratio and Z-score every 60 days. Account for transaction costs: 0.002% bid-ask spread and $0.005 per share commission for both legs. Model short-selling costs, including borrow fees.
Performance Evaluation
Key metrics: Z-score distribution of returns, Sharpe Ratio (annualized), Maximum Drawdown, Skewness, Kurtosis, and number of profitable trades. A Sharpe Ratio above 1.0 is required. Max Drawdown should not exceed 10%. Positive skewness indicates favorable tail events. Analyze the stationarity of the spread over time. A decreasing Cointegration p-value indicates a weakening relationship.
Practical Application
This strategy performs best in moderately volatile, range-bound markets. It struggles during periods of structural breaks or regime shifts. Monitor the fundamental relationship between assets. A merger or acquisition event invalidates the pair. Implement a filter: only trade pairs with a Cointegration p-value below 0.05. Re-evaluate pairs quarterly. Search for new pairs using correlation matrices and fundamental analysis. Reduce position size during earnings season for equity pairs. This avoids event risk. Consider using machine learning models to dynamically adjust the lookback periods or entry/exit thresholds. This adapts to changing market dynamics. This strategy provides a market-neutral component to a portfolio. It aims for consistent, low-volatility returns. It hedges against broad market movements. The goal is to generate alpha independent of market direction.
