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)