Investors are always evaluating the amount of risk they are willing to take for a certain expected return. Intuitively, the best investment maximizes the returns and minimizes the risks. Measuring risk and return, however, isn’t easy in the world of finance and economics. , for example, measures an asset’s sensitivity to the market movements and provides the required rate of return for exposure to the systematic risk [1]. The , a subjective measure, is the minimum return an investor seeks on an investment. Capital Asset Pricing Model (CAPM) required rate of return (RRR) Fama-French Three-Factor Model While still widely adopted, CAPM has several shortcomings [1], leading to the development of more comprehensive models. , designed by Eugene Fama and Kenneth French, appends size risk and value risk to CAPM. The model, recognizing that investment in small-cap stocks, value stocks, and volatile stocks is riskier, calculates the required rate of return with the following formula [2]: Fama-French Three-Factor Model Where: RRR = required rate of return Rf = risk-free rate of return Rm = market portfolio return SMB = size premium HML = value premium Let’s break down the formula a little bit more. The is the theoretical of an investment without any risks. risk-free rate of return return on investment (ROI) Since no investment is risk-free in the real world, government bills yield to maturity are usually used to measure the risk-free rate of return. The is the return of a portfolio consisting of all assets in the market. market portfolio return The difference between the market returns and the risk-free rate of return is called the and represents the extra returns an investor expects for exposure to market risks. market risk premium is excess returns of small-cap stocks over large-cap stocks. Small-Minus-Big (SMB) is excess returns of value stock over growth stocks. is the regression coefficient of asset returns for each factor and represents the mean change in returns for each unit of change in the predictor factor. High-Minus-Low (HML) β It is calculated using the following formula: Factors Professor Kenneth French publishes data for size premium, market premium, and value premium on his website. You can download the three factors daily records in CSV format from . this page SMB and HML are the average excess return of three small and two value portfolios over large and growth portfolios. Market premium is the excess return of NYSE, NASDAQ, and AMEX firms over one-month Treasury bills. Let’s visualize the factors' historical records (note that we calculate the cumulative sum of factors for a better visual representation of the data): factors = pd.read_csv( , index_col= ) factors.index= pd.to_datetime(factors.index, format= ) factors = factors.resample( ).mean() factors_cum = factors.cumsum() factors_cum.plot.line() "./data/factors.csv" "Date" # convert Date index to datetime object "%Y%m%d" # get monthly avg 'BM' Asset Returns We’ll use as an example for the rest of this article. Also, we get the ticker data using library. ETSY yfinance yfinance yf etsy = yf.Ticker( ) hist = etsy.history(period= , auto_adjust=True, rounding=False) price = hist[[ ]] # resample by latest monthly price monthly_price = price.resample( ).last() # calculate monthly returns monthly_returns = monthly_price.pct_change().dropna() # calculate excess monthly returns excess_returns = (monthly_returns[ ] - factors[ ]).dropna() # convert to dataframe excess_returns = pd.DataFrame(data=excess_returns.values, index=excess_returns.index, columns=[ ]) excess_returns_cum = excess_returns.cumsum() excess_returns_cum.plot.line() import as "ETSY" "max" "Close" 'BM' 'Close' 'RF' "Returns" Beta Since beta is the slope of the regression line, we can calculate it by running multiple OLS regressions–where factors are predictors and excess return is the dependent variable. statsmodels.api sm data = factors.join(excess_returns).dropna() y = data[[ ]] x = data[[ , , ]] ols = sm.OLS(y,x) result = ols.fit() betas = result.params print(betas) import as # join factors to returns dfs "Returns" "Mkt-RF" "SMB" "HML" The result is: Mkt-RF SMB HML dtype: float64 0.344029 0.257253 -0.159444 The Required Rate of Return All the necessary ingredients to calculate the required rate of return using the Fama-French three-factor model are ready. We can now calculate the RRR. latest_factors = factors.tail( ).to_dict( )[ ] RRR = latest_factors[ ] RRR += betas[ ] * latest_factors[ ] RRR += betas[ ] * latest_factors[ ] RRR += betas[ ] * latest_factors[ ] print( ) 1 'r' 0 "RF" "Mkt-RF" "Mkt-RF" "SMB" "SMB" "HML" "HML" f"Required rate of return is: " {RRR} Required rate of return is: 0.2462936811626845 You can find the source code of the article here . [1] E.F. Fama and K.R. French, The Capital Asset Pricing Model: Theory and Evidence (2004), Journal of Economic Perspectives [2] E.F. Fama and K.R. French, Common risk factors in the returns on stocks and bonds (1993), Journal of Financial Economics