Testing for Cointegration for Statistical Arbitrage and Pairs-Trading Strategies (Python)
Vložit
- čas přidán 11. 09. 2024
- 🎁 FREE Algorithms Interview Questions Course - bit.ly/3s37wON
🎁 FREE Machine Learning Course - bit.ly/3oY4aLi
🎁 FREE Python Programming Course - bit.ly/3JJMHOD
📱 FREE Algorithms Visualization App - bit.ly/algorhym...
✅ Quantitative Finance and Algorithmic Trading Bootcamp: bit.ly/3gNNNgo
In this lecture we'll use cointegration in Python to find long-term relationships between 2 assets (stocks in this case). It is crucial to know the difference between correlation and cointegration. Correlation is just short-term relationship between 2 random variables.
In our trading strategy we want to find assets (stocks) that are correlated on the long run. This is why we have to use cointegration instead.
✔️ this is the first step in mean-reverting trading strategies (pairs trading and statistical arbitrage)
✔️ if we can identify a single pair of assets that are correlated on the Long run - we can use it in our trading strategy
✔️ we can use linear regression (on historical data for the past 90 days) to determine the hedge ratio (so the position sizes of the short and long positions accordingly)
You can learn about how to implement it in Python and Backtrader in the bootcamp!
🫂 Facebook: / globalsoftwarealgorithms
🫂 Instagram: / global.software.algori...
Great one
thanks
The math is conceptually accurate, but your equation for residuals fails to consider the y intercept. The residuals should be the difference between y_actual & y_model: R = y_actual - m_model*x_actual - y-int_model. Building a trading method around the system you describe with this fundamental error might result in significant loss of any statistical advantage (depending on how the viewer proceeds). When checking for stationarity, the test involves first differences, so the y-int dissapears. that is a fortunate coincidence for you I supposed, but nevertheless your formulation and explanation are not accurate and this could lead others to losing money if they want to use the ideas here to build their own methodology.
The scarcity of good tutorial for statistical arbitrage is baffling there is some lecture but I don’t understand every little detail about it do you have free ressource you can guide me to to better understand and build my own bot?
You say on your video "CASUALLY RELATED" when I expect you mean "CAUSALLY RELATED" :-)
but dude, finding correlation of stock prices between 2011-2013 is *only* useful if you are trading between those specific years, lol. To be succesful with this, you need to find pairs that are extremely well cointegrated in the recent past, and preferably, well before that, not just a few random years in the past. Peace :-)