Pairs Watch web app is a quantitative finance tool that helps users analyze potential pairs trading opportunities.
Check out the app @ streamlit.app
Cointegration occurs when two or more non-stationary time series move together in the long run, forming a stationary linear combination.
-
Cointegration involves two steps: regressing one time series on the other to get the cointegration vector, and then perform an ADF test on the residuals of the regression to check for stationarity.
-
If the residuals are not stationary, then we are estimating OLS beta (Sensitivity), not a long-term relationship.
-
Therefore, residuals must be stationary.
-
The cointegration vector captures long term equilibrium relationship.
Regression to find the relationship (OLS assumes linear relationship, otherwise residuals will likely be non-stationary).
If the residuals are stationary, they fluctuate around a constant mean and do not drift indefinitely. Therefore, the pair is mean-reverting.
Calculating the percentiles of residuals is a great way to determine outliers that might indicate trading opportunities.
For example, if the residuals are far outside certain percentiles (e.g., the 5th or 95th percentile), that could signal that the price relationship is temporarily outside their usual bounds, creating a good chance for mean reversion (i.e., a return to the equilibrium).