### Introduction

The relationship between return and risk has long been a popular topic for research. Investors have been seeking financial models that quantify risk and use it to estimate the expected return on equity. The Fama French five-factor model, improved from the Fama French three-factor model, is one of the most classic models (Fama and French, 2015). In this post, we will discuss this model and develop a stock-picking strategy based on it.

### Method

The Fama French five-factor model was proposed in 2014 and is adapted from the Fama French three-factor model (Fama and French, 2015). It builds upon the dividend discount model which states that the value of stocks today is dependent upon future dividends. Fama and French add two factors, investment and profitability, to the dividend discount model to better capture the relationship between risk and return. The model is as follows

where

- is the excess return of the market. It is the return on the value-weighted market portfolio.
- is the return on a diversified portfolio of small-cap stocks minus the return on a diversified portfolio of big-cap stocks.
- is the difference between the returns on diversified portfolios of stocks with high and low Book-to-Market ratios.
- is the difference between the returns on diversified portfolios of stocks with robust (high and steady) and weak (low) profitability.
- is the difference between the returns on diversified portfolios of the stocks of low and high investment firms, which we call conservative and aggressive. Here, low/high investment means reinvestment ratio is low/high.

Taking inspiration from the Fama French five-factor model, we can develop a multi-factor stock selection strategy that focuses on five factors: size, value, quality, profitability, and investment pattern.

First, we run a Coarse Selection to drop Equities which have no fundamental data or have too low prices. Then we select those with the highest dollar volume.
Note that a useful technique is used here: we can use `Universe.Unchanged`

to remain the same universe when there is no necessary change, which greatly speeds up the backtest.

```
def CoarseSelectionFunction(self, coarse):
'''Drop securities which have no fundamental data or have too low prices.
Select those with highest by dollar volume'''
if self.Time < self.nextLiquidate:
return Universe.Unchanged
selected = sorted([x for x in coarse if x.HasFundamentalData and x.Price > 5],
key=lambda x: x.DollarVolume, reverse=True)
return [x.Symbol for x in selected[:self.num_coarse]]
```

Secondly, in Fine Selection, we use the terms `TotalEquity`

, `BookValuePerShare`

, `OperationProfitMargin`

, `ROE`

, and `TotalAssetsGrowth`

to account for the five factors, respectively. We then calculate a custom ranking metric for each stock using these five terms. Our algorithm will go long in the five stocks with the highest scores and short the five stocks with the lowest scores.

```
def FineSelectionFunction(self, fine):
'''Select securities with highest score on Fama French 5 factors'''
# Select stocks with these 5 factors:
# MKT -- Book value per share: Value
# SMB -- TotalEquity: Size
# HML -- Operation profit margin: Quality
# RMW -- ROE: Profitability
# CMA -- TotalAssetsGrowth: Investment Pattern
filtered = [x for x in fine if x.ValuationRatios.BookValuePerShare
and x.FinancialStatements.BalanceSheet.TotalEquity
and x.OperationRatios.OperationMargin.Value
and x.OperationRatios.ROE
and x.OperationRatios.TotalAssetsGrowth]
# Sort by factors
sortedByMkt = sorted(filtered, key=lambda x: x.ValuationRatios.BookValuePerShare, reverse=True)
sortedBySmb = sorted(filtered, key=lambda x: x.FinancialStatements.BalanceSheet.TotalEquity.Value, reverse=True)
sortedByHml = sorted(filtered, key=lambda x: x.OperationRatios.OperationMargin.Value, reverse=True)
sortedByRmw = sorted(filtered, key=lambda x: x.OperationRatios.ROE.Value, reverse=True)
sortedByCma = sorted(filtered, key=lambda x: x.OperationRatios.TotalAssetsGrowth.Value, reverse=False)
stockBySymbol = {}
# Get the rank based on 5 factors for every stock
for index, stock in enumerate(sortedByMkt):
mktRank = self.beta_m * index
smbRank = self.beta_s * sortedBySmb.index(stock)
hmlRank = self.beta_h * sortedByHml.index(stock)
rmwRank = self.beta_r * sortedByRmw.index(stock)
cmaRank = self.beta_c * sortedByCma.index(stock)
avgRank = np.mean([mktRank,smbRank,hmlRank,rmwRank,cmaRank])
stockBySymbol[stock.Symbol] = avgRank
sorted_dict = sorted(stockBySymbol.items(), key = lambda x: x[1], reverse = True)
symbols = [x[0] for x in sorted_dict]
# Pick the stocks with the highest scores to long
self.longSymbols= symbols[:self.num_long]
# Pick the stocks with the lowest scores to short
self.shortSymbols = symbols[-self.num_short:]
return self.longSymbols + self.shortSymbols
```

### Results

In this example, the portfolio is rebalanced every 30 days and the backtest period runs from Jan 2010 to Aug 2019. You can improve upon this strategy by changing the fundamental factors, the weight of each factor, and the rebalance frequency.

The Fama French five-factor model provides a scientific way to measure asset pricing. For the five aspects that Fama and French mentioned, we used one possible combination in our backtest. We can see from the results that it achieves an annual rate of return around 6.8% with a max drawdown of 19.8% over 8 years. These factors perhaps cannot capture a sufficient amount of information on the assets' pricing, and therefore, there are still many aspects can be improved (e.g. the weights of factors, a different set of factors for different kinds of Equities,etc.) We encourage you to explore and create better algorithms upon this tutorial!