Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Strategy: Momentum at a fair price + reversal in bear markets

This is my First strategy of +1 Sharpe Ratio. I would like to hear what you guys think about it and maybe some advise.

Idea behind the strategy
Going long on top momentum stocks which are not highly overvalued. Also in bearish markets going short on top gainers which are overvalued.
Value of the stock is defined by the Peg_ratio

Rules for The Strategy:
- Universe = US Equities
- Regime filter = Only goes long when SPY.close > SPY.100day_moving_average, otherwise goes short
- Longs = get the Top 50 momentum stocks, only buy ones with Peg_ratio < 1.5
- Shorts = get the Top 50 gainers, only short ones with Peg_ratio > 3
- This strategy is rebalanced once a month, at the beginning of the month
- Weighting method = equally distributed weights, no more than 20% to a single stock
- No cash reallocation

It seems to work nicely, Im not able to backtest it in a longer period since there is no peg_ratio data before 7-1-2014
I know there is lots of room for improvement such as there is a lot of cash that is not being used, and maybe I could use a more sophisticated weighting method.
Also im concerned of the small number of stocks the strategy buys

This is my first strategy, surely there are lots of flaws, I'm here to learn and will appreciate any type of feedback

3 responses

Hi Marcos,

Nice one, thank you for sharing!

I tried to recreate the peg ratio manually, so it's possible to run a longer backtest. Only somewhat successfully, as there still seems to be missing data. Maybe try some other fields for earnings growth, e.g. just Net Income, or EBIT? Also, negative growth in earnings should probably be set to null I'm thinking. There might be other mistakes as well. Have a look?

Thanks Joakim for your feedback, I'll keep working on it and post any updates.
Sadly the algo didn't pass a robustness test. If instead of algo.date_rules.month_start() you run the algo with .month_start(days_offset=1) it stops having positive results.

Hi Marcos (and hi again to Joakim after my absence from the Q Forum this year).
Looking at your strategy, Marcos, and the parameters that you are using (e.g. account size and preference for being Long in the market), it seems evident that you intended this mainly for personal investment purposes. However it can also be generalized to become a good starting point for a "Long-Short Equity" strategy suitable for entry in Q's Contest. I'm a lousy python programmer, but i tried doing this for you by taking your code and then adding some bits in such a way that all Q's Contest rules would be fulfilled. Results aren't great (yet) but there is lots of scope for easy improvement and everything stays within the required constraints for Q's contest, but with the exception that leverage goes to zero briefly on 2 occasions (Dec 2016 & Sept 2017). I'm not sure what is causing this exactly, but maybe Joakim can help us. He's smarter than i am, and also considerably more skilled at python :-))