OLS Spread Model Tutorial
Uses linear regression for optimal hedge ratio calculation and enhanced pairs trading precision.
1Understanding Linear Regression
Ordinary Least Squares (OLS) finds the best straight line describing the historical relationship between the two stock prices. This is the foundation for creating a truly market-neutral spread.
Regression Equation:
Stock A = α + β × Stock B + εα (Alpha):
The intercept term, representing the average residual value of the relationship.
β (Beta / Hedge Ratio):
The slope coefficient. This determines the optimal quantity of Stock B needed to hedge Stock A.
2Calculating the Spread
The Spread is the residuals (ε) from the regression equation. It represents the "mispricing" between the two stocks after accounting for the hedge ratio (β).
Spread Formula:
Spread = Stock A - (α + β × Stock B)💡 Key Insight:
The spread must be a stationary time series for mean-reversion trading. We expect the spread to always revert to zero.
3Statistical Significance
Before trading, we must ensure the relationship is statistically valid and the spread is mean-reverting.
R² (R-squared):
Measures the fit of the regression line. Look for values above 0.7 to indicate a strong, correlated relationship.
ADF Test (Stationarity):
The Augmented Dickey-Fuller (ADF) test must confirm the spread is stationary (i.e., co-integrated) for mean reversion to be viable.
🎯 Quality Thresholds:
Look for ADF test p-value < 0.05 and a Statistical Half-Life between 5 and 60 days.
4Trading Signals
Trading signals are generated using the Z-score of the calculated spread.
📈 Entry: Z-Score > +2.5
Spread is too high. Action: Short Stock A and Long Stock B ($\beta$ shares).
📉 Entry: Z-Score < -2.5
Spread is too low. Action: Long Stock A and Short Stock B ($\beta$ shares).
⚠️ Critical Difference:
Unlike the Ratio Model, the volume/value of Stock B must be scaled by the **Beta (β)** to maintain the market-neutral hedge.
5Advantages Over Ratio Model
The OLS model offers superior stability and statistical rigor compared to the simple ratio approach.
🎯 Better Hedging:
Optimal Beta coefficient minimizes basis risk, creating a cleaner spread signal.
📊 Statistical Validation:
R² and statistical tests provide confidence in the relationship's stability.
Ready to Implement?
Use the Pair Analyzer to run OLS, visualize the spread, and confirm stationarity with the ADF test.
Quick Navigation
Related Guides
💡 Pro Tip
Use a rolling window (e.g., 60-120 days) for regression calculations to ensure the relationship remains current and relevant to changing market conditions.