Skip to content

s1dewalker/Cointegration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 

Repository files navigation

img

Pairs Watch

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.

Summary:

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.

Strategy:

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).

img


About

Cointegration for pairs trading | Nike and Adidas

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published