This is my first article after 2 months of digging, reading, researching, and backtesting. Here I would like to share the result with people who are interested in it and welcome any thoughts from anyone.
Introduction
Before diving into this article, you can start with reading the following thoughts and see whether these are the situations that you’re facing:
- My daytime salary is stable, and I want to make some small money by investing in the stock market or ETFs
- I don’t have a finance background or experience in putting money in the stock market before
- I don’t want to spend too much time and I don’t have enough time to analyze tens of thousands of stocks myself
- I know what I should do and how to do it, but buying stocks would literally consume the rest of my day as I don’t want to lose too much money on this.
If you’ve asked these questions to yourself in the middle of the night or during work sometime, this article might help introduce you to some ideas to help you get rid of these thoughts that haunts you.
Background Story (Magic Formula v.s. Acquirer’s Multiple)
The Magic Formula was first introduced in the book “The Little Book that Beats the Market“ by Joel Greenblatt.
The formula is about using ranking of two fundamental stats: Earnings Yield and Return on Capital to quickly identify the value stocks/companies. Once we have our candidates picked, then we buy and hold them for a year and re-evaluate the performance of the portfolio annually. By applying these two numbers as your filters, you’ll be able to locate the stocks/companies that make more money (high Return on Capital, or ROC), but in the meantime is undervalued (high Earnings Yield, or EY).
And then Tobias Carlisle introduced an updated version of the Magic Formula, called Acquirer’s Multiple in his book “The Acquirer’s Multiple“.
As Buffett said, a wonderful company is the one with a high return on equity. The Acquirer’s Multiple uses operating earnings instead of using EBIT. The formula is also inverted. Operating earnings is constructed from the top of the income statement down, whereas EBIT is constructed from the bottom up.
In short, Greenblatt’s Magic Formula is looking for a company that makes money for each dollar that stakeholders invested, while stakeholders pay as little as possible. This is what Buffet has been practicing as he preached over the years. And Tobias’s Acquirer’s Multiple is to find out the company’s cashflow hidden under the iceberg. The lower the Acquirer’s Multiple, the more value you get for the price you pay and the better the stock.
In this article, I’m using Quantopian as the platform for constructing my research and backtesting the strategies to find out the result.
Reference
- 價值投資者:喬伊‧葛林布雷 (Joel Greenblatt)的神奇公式:『MAGIC FORMULA』 - by 雷浩斯
- Greenblatt builds a magic formula on Buffett style ideas - by Robert Abbott
- Acquirer’s portfolio year in review - by Ryan Boselo
- Magic Formula Strategy in Quantopian - from Quantopian
- Comparing the Acquirer’s Multiple to the Magic Formula - from Quantopian
Here comes the Meat!!
Assumptions
- Establish a threshold of market capitalization of the company (\$100M~\$1B).
- Exclude stocks in the utility and financial sector
- Exclude foreign companies ADR (American Depositary Receipts).
Formula
- Using Magic Formula
- We’re going to rank both earning yield and roic (the higher the value, the smaller number the rank)
- Add up these two ranks
- We take the top N stocks that rank the highest (top N smaller rank numbers)
- Using Acquirer’s Multiple
- We’re going to rank the calculated AM number in reverse order (the lower the value, the smaller number th rank)
- We take the top N stocks that rank the highest (top N smaller rank numbers)
Weight distribution
We are going to test how these three different weight distribution methods impact the return of our portfolio, and find out which one would be better.
- Weight evenly
- Weight by rank
- Weight by Market Cap
Let’s get started
Most research and papers have suggested that owning 25~30 stocks would adequately diversify the sector risk of the portfolio. For individual investors like us, owning that many stocks would be too troublesome. I’m thinking of using 12 as the limit. Also, we’re going to rebalance our portfolio once per year, selling losers one week before the year-mark and winners one week after the year mark. This strategy will need to continue over a long-term period (5~10 years). In this backtest, we’re using 2011/01/01 ~ 2020/07/30
as the backtest period.
How to understand the diagram?
- Blue line: returns of the algorithm
- Red line: returns of SPY (S&P 500)
- Returns: the final return of the algorithm at the end of the backtest date
- Alpha: Excess market neutral return that is generated by this strategy
- Beta: Represents an individual stock’s returns against those of the market as a whole
- Sharpe: How much returns can we get if we take one more unit of risk
- Drawdown: Maximum lost in a continuous period
- Capacity: Max number of stocks that we’re going to contain in our portfolio
Scenario 1: Buy all and sell all at the beginning of each year
Magic Formula
Capacity = 12 | Capacity = 25 | |
---|---|---|
Rank weighted | ||
Evenly weighted | ||
Market cap weighted |
Acquirer’s Multiple
Capacity = 12 | Capacity = 25 | |
---|---|---|
Rank weighted | ||
Evenly weighted | ||
Market cap weighted |
Conclusion
- Big capacity doesn’t really imply a well diversified portfolio. You could include a stock that potentially hurts the return of the portfolio.
- Seems AM does do better than MF in this scenario.
- We can’t tell which weight distribution method is better at the moment.
demean(groupby=Sector())
is a built-in factor function in Quantopian IDE. It deducts the mean of industry sector from each stock, removing part of the differences by sector. In the code we added this function, and it did help improve the performance as it has normalized the Sector risk/exposure.
Scenario 2: Buy all and sell all and use rolling data for the past three quarters
In this scenario, for all the factors such as EV, EBIT, ROIC, …etc, I’m using a three-quarter rolling mean to smooth the data. By doing this, we can mitigate the zig and zag of the quarter numbers and reduce the chances of picking a stock that only stands out in one specific quarter.
Magic Formula
Capacity = 12 | Capacity = 25 | |
---|---|---|
Rank weighted | ||
Evenly weighted | ||
Market cap weighted |
Acquirer’s Multiple
Capacity = 12 | Capacity = 25 | |
---|---|---|
Rank weighted | ||
Evenly weighted | ||
Market cap weighted |
Conclusion
- When implementing the rolling rank, I’ve noticed that a lot of stocks are missing EBIT or missing ROIC in their historic data sets, so I dropped those completely. If we had more complete data, the performance of this method might be better.
- While backtesting using the AM method, we can clearly see the return drastically decrease starting in 2016. By looking at the stocks_owned in the diagrams, you’ll see that three stocks disappeared in the middle of the year. After printing out the owned stocks for each period, we found out that the following three stocks: BMR, SWI, and IRC had either changed their symbol or been delisted from the market, resulting in part of our capital being locked down. I tried to figure out a way to update this in either the log or the portfolio capital, but found that this needs to be managed manually.
- Rank weighted distribution is the best option here as it guides us to put more capital in the better quality stocks/companies.
Scenario 3: Buy three stocks maximum per month + Adjust portfolio monthly and use rolling three quarters factors
In this scenario, we re-balance our portfolio on a monthly basis, and buy the top 3 stocks per month in order to make sure we’re able to pick the top ranked stocks. For theMarket Cap-weighted and Rank-weighted method, I discarded them as you need to adjust your positions every month. This also means, that the number of turnovers would increase quite a lot compared to in an evenly-weighted portfolio. I would rather look into this strategy later than now.
Magic Formula
Capacity = 12 | Capacity = 25 | |
---|---|---|
Rank weighted (x) | ||
Evenly weighted | ||
Market cap weighted (x) |
Acquirer’s Multiple
Capacity = 12 | Capacity = 25 | |
---|---|---|
Evenly weighted |
Conclusion
- In this scenario, we saw the stocks_owned line has very frequent movement, meaning we’re trading very frequently.
Additional step
In the magic formula, we’re actually assuming the EY_rank
and roic_rank
are weighted equally.
So what we could do is to use a linear regression to find out the relative coefficient of these two independent variables. Once we have these two coefficients, we can better describe the relation between these variables, and better predict the quality of the company with the Magic Formula.
However, after performing an OLS linear regression (it’s a basic type of linear regression in the python built-in statsmodels package ) to find out the coefficient of the two independent variables, I found out that the data set is very skewed in terms of the distribution of the daily return of the stock price across stocks. To dive into this topic further, there’re a few more things we can do:
- use
log return
overdaily percentage change
- Demean the log return by sector
But I’ll leave the thoughts here for now.
Final words
I’ll probably go with the strategy of Scenario 2, 12 assets max, with rank-weighted distribution
. The total return has constantly beaten the S&P 500 index over the years covered in the simulation. Also you got an alpha that is positive, a beta slightly over 1, an ok Sharpe ratio, and annual returns around 30% over 8 years. Even when the big slide of COVID-19 hit the market, this strategy still beat the market and was able to rebound quickly enough back to where it was.
“What can I get out of this research and backtesting?” you must be wondering. To answer the questions that we raised in the beginning of the article, I believe this strategy does bring you the benefit that:
We only need to spend 1 morning and 2 evenings in the entire year to complete the trading actions of this Magic Formula strategy.
Doesn’t this sound amazing and attractive!?
Thank you, and let me know if you have any thoughts.
Appendix
Statistics that used in the Magic Formula
- 息税前利润(EBIT) = 净利润 + 财务费用 + 所得税费用
- net_profit 净利润(元)
- financial_expense 财务费用(元)
- income_tax_expense 所得税费用(元)
- 固定资产净额(Net Fixed Assets) = 固定资产 - 工程物资 - 在建工程 - 固定资产清理
- fixed_assets 固定资产(元)
- construction_materials 工程物资(元)
- constru_in_process 在建工程(元)
- fixed_assets_liquidation 固定资产清理(元)
- 净营运资本(Net Working Capital)= 流动资产合计-流动负债合计
- total_current_assets 流动资产合计(元)
- total_current_liability 流动负债合计(元)
- 企业价值(Enterprise Value) = 总市值 + 负债合计 – 期末现金及现金等价物余额
- market_cap 总市值(亿元)
- total_liability 负债合计(元)
- cash_and_equivalents_at_end 期末现金及现金等价物余额(元)
Here I also attached the Quantopian code that I used to construct the research this time:
Quantopian code
1 | from quantopian.pipeline.classifiers.fundamentals import Sector |