Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Fundamentals Morningstar Ratings

This algo lets Morningstar do the legwork, every month it buys all the stocks trading above their N day (100 here) moving average that have A or B growth and profitability grades from Morningstar. Any remaining capital is put into long term bonds (TLT) to stay 100% invested.

David

16 responses

Hi David,

Thanks. The idea looks very interesting. It seems the code trades a lot because of the diversification of stocks. I tested starting with $20K (my trading cash..) and add a commission of $2 per trade, here is the result. But this method should work great if given more starting cash.

Best,
Han

Nice use of fundamentals Dave. I think I'll use your model for future study (if you don't mind).

Sadly, during 2014, Dave's original strat only made 5.8% (1/1/2014...) I believe this will become a common theme here: excellent theoretical returns over 10+ years (a noble goal), but with paltry returns in 2014 -- which will eliminate such strategies from contention for selection in the Q-Fund. This leads me to believe that the Q-Fund, who's parameters have been established in a rather strong bull market, over a very short period, may have trouble in the near future.

I wonder how those strategies, shown in the Q-Fund webinar video, would perform in such a 10+ year test like the one above? When the regime changes, will you be ready? Will your strategy?

Han,
I had that set to trade up to 200 stocks, $20K is way too little for any strategy trading that many assets. I kept your settings for this one, but dropped it to 20 stocks and have it only take Morningstar A grades.

Anony, I'm not sure which one my 'original stat' is, but that's to be expected, especially if it's a long only/long term strat, let it paper trade, it's not over yet.

David

I see. The result is very impressive. Thanks.

Notice the holding of value 2008, maybe thanks to bonds, I'm not sure.
This message edited to not waste people's time.
I had expressed some doubts

Gary, you're right, it looks like it shorted VRNT and PBHC, a check for open orders seems to have fixed that. The transactions and positions in the full backtest seem to disagree with your logging sample btw, it looks like it bought and sold a lot of different stocks throughout the test, much more than 34 anyway.

David

You're right, it trades tons of them. When schedule_function is in place, due to the sequence of functions, there is no opportunity in handle_data to make use of get_open_orders for home-grown accounting, I didn't realize that previously. It can be done with another schedule_function to one's own accounting function. This has 1/10th the initial number of stocks and has an example of some run summary code, updated to do the right thing when schedule_function is present (I think).

Give this a spin ...

Would it be possible to get a Q2 version of this to play with?

Haas anyone had success over the week on getting this to work with Q2?

Just giving this a final bump to see if there is any interest.

thats awesome, i was wondering how their grading performs. I'm always surprised that grades, forecasts, indicators, none of it does very well. maybe i code it wrong.

Hi all,
I took some time to port this over to Q2. Now, all the stock data and filtering is generated through Pipeline, using the same Morningstar fundamental data.

The algorithm seems to hit the cap of 200 stock picks a day, leading me to believe that the pipeline is capable of generating more accurate data from Morningstar. As a result, the amount of capital held in bonds is much lower throughout the algorithm.

Also - instead of arbitrarily picking 200 stocks out of our selection, I pick the 200 stocks with the lowest difference between moving average and close price. The way the 200 stocks are picked is something you all should play around with.

Let me know if you guys have any questions!

Matt

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Matthew, thank you for your port! Last night before I went to sleep, I also managed to get something working without any deprecation warning, but it does not look or perform anywhere close to as nice as your code does. If anyone is interested, I can post it so that you guys can compare the differences, if anyone is interested. Just be forewarned, it's not pretty.

Changing the stock count from 200 to 20 drives this algo to insane amounts of leverage. I tried changing various things around, and I can't figure out why. Is it possibly the way the buy/sell logic is implemented? I've attached a backtest with only to 200 to 20 change.

That was because the number 200 was hard coded into some part of the algorithm. I've updated it to instead use num_stocks. The performance with 20 stocks still isn't great - but the leverage is reliable now.

I messed around with it a little bit, and tried porting the RSI code from another algorithm over, but its looking like the Morningstar ratings might be a bust.