Calculating Expected Returns of Stock using CAPM

Image source: Medium

Capital Asset Pricing Model(CAPM) is a popular model in finance for calculating the expected return of investments in the stock market. I’m going to explore it in detail in this post.

CAPM calculates the expected return using the below formula

Let’s dive deep into these variables.

Risk-free Rate

Historically, U.S. Treasury bills, notes, or bonds are considered as risk-free investments because they are fully backed by fed and are guaranteed to be paid no matter what. Yield rates of Treasury bonds vary depending on the term of the bond. Longer the maturity term, the better the yield rate. Financial analysts consider the yield rate of 10-year Treasury bond as a standard risk-free rate for calculations.

Image source: Ycharts

The current yield rate of 10-year treasury bond is 1.74%. So the first variable Rf is 0.0174.

Beta

Beta is a measure of correlation. Beta effectively describes the investment volatility with respect to the overall stock market. It is calculated as follows

r(i) = Return of the invidual stock

r(m) = Return of the overall stock market

Beta is basically the ratio of covariance of the stock to the variance of the market.

To calculate beta, we first need to calculate the returns of the stock and the stock market. For this example, I would use Cathie Wood’s ARK active funds. ARK ETFs gained immense popularity lately due to their stunning performance.

Simple Returns

Let’s calculate the simple returns of S&P500 and ARK funds.

# Calculating simple return
stock_returns = (stocks_df - stocks_df.iloc[0, :])/stocks_df.iloc[0, :]*100
# plot the rate of return over time
stock_returns.plot(legend=True, figsize=(14, 8), linewidth=1)
plt.axhline(y=0, linestyle='dashed', color='black', linewidth=1)
plt.xlabel('Year')
plt.ylabel('Return %')
plt.title('S&P 500 and ARK ETF Returns in last 5 Years')

From the plot, we can see that ARKK ETF has outperformed the market by a large margin. A lot of its success is due to Tesla($TSLA) which has a holding share of more than 10% and other innovative companies like Zoom, Teledoc, Shopify, etc.,

Log Returns

Simple returns are asymmetric in nature. What I mean by that is, if a stock value goes from $10 to $20 then returns are 100% and if it goes down from $20 to $10, returns are not -100%. Log function keeps this behavior consistent.

#Math
Log(10/20) = -0.30
Log(20/10) = 0.30

Python code for calculating log returns:

log_returns = np.log(stocks_df/stocks_df.shift(1))#Note: Shift function shifts data by desired number of periods. Shift(1) moves the data by 1 period. So, the expression becomes log(current_value/previous_value).

Beta calculation

Beta value is normally calculated using log returns since the log function keeps the change in value symmetric.

#Covariance of the log returns
returns_cov = log_returns.cov()
# There are about 252 trading days in an year
annual_cov = returns_cov*252
annual_cov
market_var = log_returns['S&P500'].var()
market_var
##Output: 0.0001412928728106657
annual_mkt_var = market_var*252
annual_mkt_var
##Output: 0.03560580394828776

The stock market gets a beta value of 1. As you might already know, S&P 500 index is usually referred to as the market index.

# Beta is the ratio of annual covariance of the stock to annual market variancebeta = annual_cov/annual_mkt_var
beta

In investing world, beta > 1 signifies a stock that is more volatile than the market. More the volatile the stock is the riskier it becomes. Similarly, Beta < 1 signifies a less volatile and less risky stock.

Finally, CAPM

Take a look at the first formula again. Historically, market returns are around 8% annually. So, we would take 0.08 as market returns. We already know the risk-free rate(0.017) and beta values(calculated above). Let’s calculate the expected returns for ARK funds.

Expected returns using CAPM

from collections import defaultdictreturns_dict = defaultdict()tickers = [ 'S&P500', 'ARKK', 'ARKG','ARKQ']for ticker in tickers:
returns_dict[ticker] = round((0.017+beta[ticker]['S&P500']*(0.08-0.017))*100,2)
#print the expected returns of the stock
for idx, val in returns_dict.items():
print(idx,'expected annual returns would be',val,'%')

That’s all! ARKK has the highest annual returns at 9.45%.

In my opinion, CAPM expected returns are very conservative. ARKK has Compound annual growth rate(CAGR) of more than 40%. In simple words, it has returned more than 40% annually in the last 5 years.

Also, note that CAPM doesn’t factor in the expense ratio of the ETFs or mutual funds. Some of the actively managed funds are more expensive than passively managed index funds. So, you should keep that in mind while choosing your investment options along with their volatility and expected returns.

I will have the code updated in my GitHub soon. I will talk more about CAGR and Sharpe ratio in my next article.

Data enthusiast! Loves to learn.