Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Quality Companies in an Uptrend

This algorithm extends Chris Cain and Dan Whitnable's work. I used Chris's algorithm structure, Dan's Quantopian implementation, and created my own composite factor of Morningstar fundamentals.

To repeat Chris Cain, the structure of the algorithm is
1. High Quality: Take the top 50 stocks with the highest composite score
2. Strong Momentum: Buy the 20 stocks with the strongest relative momentum, skipping the last 10 days to account for mean reversion over this shorter time frame
3. We only enter new long positions if a "bull market" check is passed, indicated with a 50 day Simple Moving Average (SMA) of SPY exceeding the 200 day SMA.
4. This strategy is rebalanced once a month. We sell securities that are no longer in our high quality and strong momentum list and replace them with stocks that have since made the list.
5. Any cash not allocated goes to the IEF (7-10yr US Treasuries)

4 responses

I chose the fundamentals for my composite factor using the attached analysis (click below) and Alphalens.

I also explored shorting in bear markets according to the composite factor, but it hurts returns and the Sharpe ratio. However, it did boost alpha and reduce beta as expected.

The strategy for shorting mirrored the long strategy
- Short the lowest quality and weakest momentum stocks
- Only enter short positions in a bear market. I indicate a bear market with 50 day SPY Simple Moving Average (SMA) < 100 day SMA < 200 day SMA. The purpose is to carefully short only when there is consistent bearish behavior and quickly exit when there isn't. This would be for long-term shorting.

Hi Sam

Nice work and a lot to think about. I highly appreciate the effort put into the fundamentals research notebook work.
I backtested 2010-2020 , and the result aren't as impressive. Most gains in the original backtest you posted are in the 2008-9 financial crisis, where you moved to IEF. And those just kept rolling on.

Any thoughts on improving performance, especially regarding 2015-6 onwards?

Thanks for the illustrative backtest, Morag! This is a great point.

Since this a long only, monthly rebalanced strategy, I would worry that drastically improving recent results would involve overfitting the fundamentals composite. This is because this strategy is long-term at its core.

I believe incremental improvements lie in revising the fundamentals composite according to your belief of what a "quality" company looks like. If you correctly add fundamentals that are presently related to long-term performance, they will improve results. However, the signal from these fresh fundamentals may take some time to flush out.