Momentum - filter stocks

Hi,



in the following code the idea is to get the average dollar volume:

Filter the top 100 stocks

filtered_stocks = (stocks_price[:90] * stocks_volume[:90]

                   ).mean().sort_values(ascending=False).index[:100]



filtered_stocks_prices = stocks_price[filtered_stocks].dropna()


Print columns of the filtered_stocks_prices dataframe

filtered_stocks



My question is:

since I am filtering the first 90 rows there is a problem because I am selecting the first 90 trading days to backtest the stocks for the whole periodo of 11 years!



In my opinion it should select the highest average dollar volume for each quarter or each month, or any other period. The only case that is not acceptable is to work with a static list like we are doing. It is a down side bias.



Because we may have new stocks with higher dollar volume which was not trading in the first 90 days of the dataset. Imagine a company that started trading in the last 5 years and has a huge dollar volume, in this case it is not considered!



Does it make sense?

Hello Erich,



You are right. You can re-filter the stock universe at the start of every year. This was done for illustration.



You might want to try out different lookback periods for filtering. Like you can take 180 days instead of 90. 90 was taken here as we are selecting the top 20% of stocks. We thought that past 90 days of data is accurate to capture that. Also, we don't want to be very precise as idea is to capture top 20% +/- 10% stocks in the portfolio that work well with momentum.



You can also perhaps try taking a cross-section of more than 100 stocks. 

Hi Akshay,



thanks for your reply. Could you help me on coding an example filtering at the start of every year? It would be very helpful and more realistic example.



I am not considering how many days (90 or 180 or any other) are accurate but the logic itself. As I said before I dont think this example was correct since we are considering static 90 days (could be 180 or 360 or any other period and still would be incorrect) and in this case we are not capturing stocks that entered in our list after this 90 days or stocks that did not have higher volume in the first 90 days but on the last two years for example.



Since we are backtesting 10 years of data does not make sense to consider a filter of initial 90 days to evaluate the whole dataset. I would love to see an update on the notebook to reflect a more realistic approach on this exercise.



Please take this as a feedback to improve the course.



Thanks

Hello Erich,



Thanks for the feedback here and in the call. We'll be adding more material for this section. We will also be adding more code material for the momentum crash and risk management sections. We will keep you in the loop.

Hello Erich,



We have added awesome new notebooks which you can checkout. Thanks.