Hi, I have a dataset of stocks (2007 - 2021) that I want to backtest my strategy on. This dataset I have bifurcated into parts:
- In sample (this is the past dataset that I will run the backtest on and make optimisations to the strategy basis the results from the backtest). This is approx from 2007-2015.
- Out of sample - the optimised strategy I will then run on this dataset to understand how it would perform between 2016-2021.
I have already run some backtests and through that, one thing that I have come to realise is that my strategy is momentum based and hence will work only on stocks that have momentum or have had momentum in the past.
Considering this, does it make sense to exclude those stocks which have not had any momentum in the past and run the strategy on only those set of stocks which have exhibited momentum in the past?
Hi Varad,
When you say, you realised that your strategy is momentum based, there could be either of the following 3 possibilities:
Scenario 1)
Without running the backtest on the in-sample data, you figured that the strategy is designed to work well on stocks that have a strong momentum. This may be based off, on the very nature of the strategy that you have coded.
So if this is the case, then even before running any backtest on either, the in-sample data or the out-of-sample data, you can create a momentum-based filter, so as to restrict your stock universe to just high momentum stocks.
Scenario 2)
You ran some backtests on the in-sample data, and from the results, you concluded that the strategy seems to be working better on momentum-based stocks.
Given this scenario, you can definitely consider enhancing or fine-tuning your strategy further. One way to achieve this would be, to exclude stocks that have not displayed a strong momentum in the past. You can give it a try and then run the backtests on the out-of-sample data to see if the strategy seems to be giving decent or better returns.
Scenario 3)
You ran backtests on both, the in-sample as well as the out-of-sample data, and based on the results, you found that the strategy could have performed much better, if you were to exclude stocks that had a low momentum.
In cases where you have already backtested your model on both, the test (in-sample) and the train (out-of-sample) datasets, you should not try fine-tuning the strategy anymore. Such enhancements may lead to your model being overfitted. You can learn more about overfitting and similar other ML related concepts, by visiting this article here.
I hope this helped.