Mean reversion in emerging market stocks
Hello... This is the best way to keep it simple! Hi! Here is the full code: #run Ordinary Least Squares regression to find hedge ratio and then create spread series df1 = pd . DataFrame ( { 'y' : y [ 'price' ] , 'x' : x [ 'price' ] } ) est = sm . OLS ( df1 . y , df1 . x ) est = est . fit ( ) df1 [ 'hr' ] = - est . params [ 0 ] df1 [ 'spread' ] = df1 . y + ( df1 . x * df1 . hr )