I am interested in testing strategy with trades pairs that are cointegrated and enter/exit based on stochastic signals. The steps are 1) find cointegrated pairs within a universe, e.g., stocks in S&P 500, 2) calculate stochastic for the stocks in the pair, and buy or sell the pair if one is overbought and the other is oversold based on stochastic. I found some tutorials around cointegration while there are missing pieces. Is there example for such a model or how to build one? Thanks!