Get startedGet started for free

Compute dynamic stock Beta

Suppose Elon Musk is your idol and you are considering investing in some Tesla stocks. As a shrewd portfolio manager, you decide to do due diligence by checking Tesla stock Beta over the years. Beta is a measure of a stock's volatility in relation to the market, which can serve as a gauge of investment risks.

Recall you need the stock volatility, market (S&P 500 as a proxy) volatility and their return correlation to compute Beta. Correlation can be computed from standardized residuals.

Model fitted volatility has been preloaded for Tesla in teslaGarch_vol, and for S&P 500 in spGarch_vol. In addition, model standardized residuals are preloaded in teslaGarch_resid and spGarch_resid respectively.

This exercise is part of the course

GARCH Models in Python

View Course

Exercise instructions

  • Compute the correlation coefficient between Tesla and S&P 500 using standardized residuals from fitted GARCH models (teslaGarch_resid, spGarch_resid).

  • Compute Tesla stock Beta using Tesla volatility (teslaGarch_vol), S&P 500 volatility (spGarch_vol) and correlation computed from the previous step.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Compute correlation between SP500 and Tesla
correlation = np.corrcoef(____, ____)[0, 1]

# Compute the Beta for Tesla
stock_beta = ____ * (____ / ____)

# Plot the Beta
plt.title('Tesla Stock Beta')
plt.plot(stock_beta)
plt.show()
Edit and Run Code