Mean Reversion Strategies

Hello There:



 I am currently taking the mean reversion strategies in Phyton, and I would like to know somethin abor mean reversion strategy.



In this video: Quantra by QuantInsti | Courses on Algorithmic and Quantitative Trading



It says that the number of period for calculating the mean (N), and the number of standard deviations from the mean for calculating the Bollinger Bands (X) should be optimazed using a training data set.



How do you compute those parameters??  





Thanks a lot

Hi Ghery



You do not need to calculate the parameters separately. You need to choose the values for "N" and standard deviations. In the notebook corresponding to the video, we have taken "N" as 5 and the standard deviation as 0.5. 



If you wish to optimize these parameters as mentioned in the video, you can use a "for" loop and check through multiple values of these parameters to see which one gives a good result.



You should ideally divide your dataset into two parts, one part called training and the other called test set. As per the notebook, we have taken the data from 2015 to 2021. You can divide this into an 80:20 ratio, as a train-test split. You can perform the optimization exercise on the training set and use the parameters so obtained on the balance 20% test dataset.



Hope that answers your query. Feel free to reach out for any further clarifications.