Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Adaptation from the Little Book that Beats the Market

First backtest, used to help me begin understanding how to utilise the API.
Any suggestions on variations of the ratios used and rebalancing period would be appreciated.

Strategy loosely based off that from the Little Book that Beats the Market.

2 responses

You might have a look at this algo:

https://www.quantopian.com/posts/quantcon-nyc-2017-advanced-workshop

Specifically, you could use the rebalance function given there, instead of yours. It uses the Q optimization API, which allows you to address various risk factors systematically (and takes care of all of the ordering code).

So I tried to implement the exact "magic formula" that is described in the book which goes as follows

(From Chapter 15 - Step by Step Instructions):

The filtering criteria are the following:
- The author suggests starting with a list of companies with a market cap of at least 50 million dollars
- The author suggests not including utilities and financial sector stocks or foreign stocks
- Filter stocks to keep those with a return on capital of greater than 25%
- Filter stocks to keep those with a minimum price to earnings ratio of 5.0
- Sort stocks by ascending order of pe ratios

The process to follow:
- Add the top 5-7 stocks every few months, after each stock reaches a one-year holding mark, sell the stock and replace with a new stock
- Continue this process for a minimum of 3-5 years

The overall assessment of the performance of this algorithm is not so encouraging as you can see from the attached backtest - a quite large beta showing a heavy correlation to the market benchmark (SPY) - mediocre returns less than the (SPY) along with a significant drawdown especially at times when the market is not a strong bull market (2012). This algorithm also fails to avoid style and sector risk (especially that it seems most of the stocks that fit into the filtering criteria belong to three main sectors) -

Overall it seems like buying the S&P is a much wiser decision rather than sticking to the approach described in the book.

I would really appreciate any feedback on my implementation of the book's algorithm.

The main alpha factors assumed here are the return on capital and pe_ratio, which I would also want to inspect using alphalens to provide even deeper insights and also look at their combination to see to what extent combining them works well ...

I guess intuitively speaking - you might think a good 'return on capital' makes sense as an alpha factor to consider but really it just might mean that a company has a relatively small capital investment, hence a lower barrier to entry. Profitable companies with a durable competitive advantage tend to have considerable capital and hence a likely low return on capital ratio (in other words since roic is a ratio of 'net income' to 'capital' it is hard to tell if it is a large ratio due to a large numerator or due to a small denominator). Also while a stock priced at a low P/E ratio might seem to be attractive to buy, it is more than likely cheap for a good reason that is better reflected by looking at other fundamental metrics of a company.