Introduction
The Price to Earnings ratio, also known as the P/E ratio, is the ratio of a company's market price per share to the company's earnings per share.
\[P/E \ Ratio =\frac{p}{EPS}\]
where \(p\) is the stock price and \(EPS\) is the earnings per share from the most recent financial year. The P/E ratio is often used by investors to determine the valuation of a company's stock. Research suggests that a portfolio that consists of stocks with relatively low P/E ratio outperforms a portfolio that consists of stocks with relatively high P/E ratio.
Method
We pick the 10 stocks that have the lowest P/E ratio in our universe, at the beginning of each year, and we invest an equal amount of capital in each stock.
To construct the universe, first, we eliminate stocks which don't have fundamental data and stocks that have a lower price than $5 per share, using the CoarseSelectionFunction.
def coarse_selection_function(self, coarse):
if self.time.year == self.year:
return self.symbols
# drop stocks which have no fundamental data or have low price
coarse_with_fundamental = [x for x in coarse if x.has_fundamental_data and x.price > 5]
sorted_by_dollar_volume = sorted(coarse_with_fundamental, key=lambda x: x.dollar_volume, reverse=False)
return [i.symbol for i in sorted_by_dollar_volume[:self.__num_coarse_stocks]]
Then, in the FineSelectionFunction, we retrieve the list of 10 stocks, that have the lowest P/E ratio.
def fine_selection_function(self, fine):
if self.time.year == self.year:
return self.symbols
self.year = self.time.year
fine = [x for x in fine if x.valuation_ratios.pe_ratio > 0]
sorted_pe_ratio = sorted(fine, key=lambda x: x.valuation_ratios.pe_ratio)
self.symbols = [i.symbol for i in sorted_pe_ratio[:self.__num_stocks_in_portfolio]]
return self.symbols
In OnData(), we buy the 10 stocks that have the lowest P/E ratio in our universe. We rebalance the portfolio at the beginning of each year.
Summary
The portfolio significantly outperforms the benchmark, S&P 500, during the three and half years backtest period, from the beginning of the year 2016 to July of the year 2019.
The universe of stocks is filtered using dollar volume and price criteria. Most of the stocks chosen by the algorithm during the backtest period are small market capitalization stocks.
In theory, there is an additional factor to the small P/E ratio factor contributing to the excess returns of the portfolio relative to the benchmark. This additional factor is known as the size factor, where size in this respect, is the market capitalization of a stock.
Ranking portfolios on market capitalization and subsequently tracking their performance has demonstrated that portfolio of stocks with a small market capitalization outperforms a portfolio of stocks with large market capitalization. Another investment strategy in the strategy library, Small Market Capitalization Stock Premium, demonstrates how to form a portfolio that only consists of stocks with relatively low market capitalization.
Reference
- Persson E, Ståhlberg C (2006). P/E and EV/EBITDA Investment Strategies vs. the Market (Master's thesis, Linköping University, Linköping, Sweden). Online Copy
- Fama, Eugene F. and French, Kenneth R., Multifactor Explanations of Asset Pricing Anomalies. J. OF FINANCE, Vol. 51 No. 1, March 1996. Available at SSRN: https://ssrn.com/abstract=7365
Derek Melchin
See the attached backtest for an updated version of the algorithm in PEP8 style.
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Alethea Lin
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!