Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
A modified momentum measure (different to percent change)

Fairly new and inexperienced to the Quantopian platform (well not in terms of when I first joined, but in terms of time committed due to procrastination). I thought the best way to learn would be to try and put something together and share it. I thought the process of writing the algorithm to test my theory would help me to learn the coding required for Quantopian and any discussion generated afterwards would be beneficial in helping me learn how to communicate with this community.

A lot of the momentum systems I've come across use a simple percentage change over the last x days to measure momentum. This is simply the price today less the price x days ago (for simplicity let's call x 200 days), as a percentage. I see 2 flaws to this:

  1. This makes the calculation quite dependent on only 2 prices (today and price 200 days ago) in the entire 200 day lookback period.
  2. While the price change is normalized for overall price magnitude (by taking the percent change), some stocks are much more volatile than others. Doesn't it feel like a very stable stock that has risen 50% in 200 days has more momentum behind it than a very volatile stock up 50% in 200 days?

To try to correct for this we can:

  1. Take a simple moving average at each of these 2 price points. As in, today's 200 day SMA, less the 200 day SMA 200 days ago.
  2. Instead of normalizing by price, normalize by the volatility, using the recent average true range.
  3. I did apply a filter as well that the stock had to have positive momentum.

Note - I've applied a simple market gate (to both examples) of exiting positions when the SPY drops below the 200 day MA (using 200 day again for consistency).

With these 3 changes applied, the returns stayed almost the same, and risk reduced significantly, making overall performance much better.

I've attached a notebook to this post and I'll attach both my backtests in following posts, so you can see the code as well.

This is not a complete system, it just aims to show that it may be possible to increase the performance of momentum systems by using a modified measure of momentum instead of "percent change over time" as a momentum measure. Like I said, I'm a beginner, so if you see errors in my code, errors in my reasoning, errors in my haircut in my profile photo, just let me know and I'm happy to learn.

Thanks all.

4 responses

This is with the original percent change momentum calculation.

This is with the modified momentum calculation. Slightly less total returns (13.2% pa to 12.5% pa), but everything else looks much better.

How exaclty do you normalize by volatlity versus price? Im new here and learning, thanks for the help.

Essentially you divide the change in price by a volatility measure. This helps you see if the price has moved a lot in the last 200 days relative to how volatile the stock is. Assuming you have 2 stocks that have both increased by $100 over the last 200 days. Calculate the volatility of both using any measure (in this case we use ATR (see wikipedia link) which you can think about as the size of an average candle or daily bar for the stock. Assuming you have a stock that moves on average $1 per day and a stock that moves on average $10 per day.
Before dividing by ATR, both stocks show a $100 movement over the last 200 days. But once you divide by ATR, you see stock 1 has moved 100 times its daily movement, while stock 2 moved only 10 times its daily movement over the same time period. Hence it seems like stock 1 has had a more significant move relevant to stock 2, which you only see by dividing by the ATR.