Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
A quantitative value investing strategy using fundamental data

Quantopian's new offers on fundamental data is very interesting. I wrote a simple strategy based on quantitative value investing and I share the results here. The rules are as follows:

  1. select no more than 15 stocks that satisfy the following rules: P/E < 12, P/B < 2, ROE > 15%, market cap > $100M
  2. hold the selections for one year, and re-do the selection next year

The results are in good agreement with classic value investing theories. Value stocks tend to outperform market in the long run, but when economy is bad, value stocks are hit harder than normal stocks. That's why you see that although the strategy outperformed the market by almost twice, the max drawn down calculated by Quantopian is as high as 70%.

I found the new object fundamentals not that easy to use. There is not a comprehensive table describing what valuation metrics are there in the fundamentals object, and I have to search in the pop out textbox after I type the . after fundamentals, and for some reason the search don't work all the time. Also there is no explanation on how the valuation metrics are calculated. For example the P/E ratio is calculated based on earnings of the quarter or the year, or it is a forward P/E. I hope Quantopian can provide better documentation on how to use the fundamental data. Otherwise it is difficult to write better strategies.

Finally I think the fundamental data is great for back testing, but I am a little skeptical about using fundamentals to do algorithmic trading. After all trading strategies based on fundamentals are relatively long term strategies, and you usually need to look more carefully on the business and accounting of the company rather than simply using the valuation metrics to make trade decisions. So the back testing results using fundamental data would be helpful for trading decision, but it could hard to make trading decisions solely on the fundamental data.

That being said, I think if the fundamental data can include future event dates, that could be more helpful. For example, if Quantopian can provide a calendar for all the earning release date for stocks, users can trade based on the released earnings. That should be more suitable for algorithmic trading.

Let me know your thoughts and suggestions. Thanks.

21 responses

Hi Peter,

Thanks for posting the first algo with fundamentals and thanks for the feedback. We're definitely talking to vendors about event type data.

I agree it can be a bit tough to find the different fields just through the IDE type ahead function. We do have each field listed out (auto-generated from the data) here: https://www.quantopian.com/help/fundamentals

We linked to it from the main docs, but obviously not clearly enough :-) Short term, we'll make that link more prominent. We'll also look to see if there are other documentation sources that we can find for the community that give deeper definitions.

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.

Hi, Josh,

Thanks for your reply. The link is very helpful, but I don't understand how I can get there. If I click "HELP" on the top right corner of Quantopian, it has two options of "FAQ" and "HELP & API DOCS", and there I didn't find the links to the page that you posted. How can I get to that page if I don't simply click on the link you provided?

-Peter

There's a link inside the Fundamentals section with the anchor text "Fundamentals Reference" currently. We're going to make other links to that page more prominent in the short term so it isn't so hard.

Thanks for those criteria Peter. I tried to come close with this on FinViz, and then the tickers tab to be able to drop them into my existing algo. That's a static snapshot.
Of course this code dynamically adds and removes stocks that meet the criteria, happens to have started with only one (KLU) at the beginning in 2002 and winds up covering 359 total as they come and go. Some questions for anyone interested ...

Looks like only about 1/3 of them wind up being purchased. Why is that? Is there a bit of a tweak that could increase the participation?
Those purchased are often just a single buy.

Sector and rebalancing algos are pretty popular, so when order_target_percent() is in use I wonder if there is a way to (not necessarily eliminate, instead...) shy away from negative cash, this algo borrows $1.2 million.

Powerful stuff, that get_fundamentals(). Thanks.

I think the problem is that KLU went bankrupt and there is no way the algorithm can sell KLU. Because the position of KLU can not be sold into cash, but the algorithm needs to buy other stocks, and that is how the $1.2 million is borrowed. Is there a way to get around the problem of bankruptcy? Anyone has any good idea?

wrt Peter's suggestion of a earnings calendar, would the "file date" field under "earnings report" be a good way to identify the earnings release date of a stock?

I would like to prevent an algorithm from trading a given stock on/before its earnings date, or close a position if a earnings release is imminent.

Peter, to handle bankruptcy, I do the following:
Check for old un-executed orders. Cancel those orders and add the securities to a "black list". Determine the real portfolio value using the portfolio holdings minus any stocks in the black list. Execute trades based on this "real portfolio value" instead of what is reported by the API. I still like to use the "order_target_percent", so I just correct my percentages by multiplying them against the ratio of real portfolio value to reported portfolio value. I'll hack at this algo as a demonstration if I get a chance.

@Robby F, the file date does reflect the earnings calendar, but only after the fact. So with AAPL, for example, the file date (and EPS) looks like this:

2014-07-21handle_data:78INFO EPS: 11.69  
2014-07-21handle_data:79INFO File Date: 2014-04-23  
2014-07-22handle_data:78INFO EPS: 11.69  
2014-07-22handle_data:79INFO File Date: 2014-04-23  
2014-07-23handle_data:78INFO EPS: 11.69  
2014-07-23handle_data:79INFO File Date: 2014-04-23  
2014-07-24handle_data:78INFO EPS: 1.29  
2014-07-24handle_data:79INFO File Date: 2014-07-22  
2014-07-25handle_data:78INFO EPS: 1.29  
2014-07-25handle_data:79INFO File Date: 2014-07-22  

I'll add earnings calendar to the list of data sources the community is interested in.

Ray, thank you for your suggestion. I think the problem is that in the case of this algorithm, it ordered 100% on the bankrupted stock KLU. I can black list the stock as you suggested, but then I wouldn't have any cash to trade other stocks.

Anyone from Quantopian can suggest what is the official way to deal with the position in bankrupted companies?

Peter! You have done me a great service today. That was a flaw in the way I handle Quantopian's questionable tracking of dead securities. Thanks to you, now I also check for the securities "end_date" property to make sure it isn't more than a day old - then it also gets added to the blacklist.

As for this poor algo - it indeed does go 100% into a soon-to-be bankrupt company. Thanks to the slippage model, it never gets around to spending all of the cash and so about 1/3 is left at the delisting. This algo pick a few bankruptcies - at the end of the backtest, it was the proud owner of dead paper in KLU, GM, MIR, and NOVL. Unfortunately, this fake value (the value at delisting) gets reported in the blue "algorithm" line.

So what I do is compute a "real_value_ratio", which is the proportion of the portfolio held in actively trading equities. I record that as well as the cash - the original algo was going negative since it was basing order percentages on the false portfolio value. I'll try another run with this algo where I limit the maximum exposure.

Better, better. I limited exposure to a single security to 25% of the REAL portfolio value. This limits the impact of that horrendous start.

Thanks, Ray, for the posting! This is indeed a better way of dealing with dead securities. I will adopt it too.

@Josh, is there a way to determine through the fundamentals API if a company is an ETF? ETN? Thanks!!!

The fundamental data only includes data for companies. So there is no explicit field that indicates that an entry in the fundamental data is an ETF or not since ETFs are not present in the data at all. The best we can offer at this point is that the absence of a security indicates that it is likely an ETF.

Thanks
Josh

Josh,
When are you guys going to tackle our quantitative value algorithm? I wrote a whole book dedicated to these systems.
http://blog.alphaarchitect.com/2014/10/07/the-quantitative-value-investing-philosophy/
there is a high level on the algo.
1. identify universe.
2. eliminate turds via forensic accounting algos -- boot 5% worst
3. screen cheap -- we use ebit/tev, but use whatever you have data on. top 10%
4. screen quality -- we have a bunch of stuff, but you can simplify. top 50% of the step 3 survivors. You can also replace with momentum if that is easier from a data standpoint. Mom/quality do the same thing if your quality algo is good.
5. rebalance

We've found that the class of value algorithms that 1) buy cheap and within #1) buy quality, do well.

btw, this is a long duration "arbitrage" not a prop trade. So tracking error and relative pain should be insane. But that is good news if you don't like competition.

Wes, I have partially replicated the quantitative value strategy, with a few tweaks. The returns are interesting, getting 750% return between 2004 and 05/2016. Be happy to share it with you if you're interested.

Sunil

Hi Sunil, I would be interested to work on it as well

Sunil,
sounds great. Happy to check out. Feel free to share with the community -- love to have people tear our ideas into shreds and see if they can make them better.

Wes, that's a good idea. I should strip out all the extra cruft that I've added to the algorithm so that it's easier to read and evaluate on its own merits. Will try to put together the simplified version and post later today.

Sunil

I have just posted the core piece of the quantitative value algorithm at https://www.quantopian.com/posts/partial-implementation-of-quantitative-value-algorithm