Equity Beta: What Is, Example, Formula, How to Calculate Stock Beta in Python

What is equity (or stock) beta?

In finance, beta measures a stock’s volatility with respect to the overall market. It is used in many areas of financial analysis and investment, for example in the calculation of the Weighted Average Cost of Capital, in the Capital Asset Pricing Model and market-neutral trading.

In this post, we present a concrete example of calculating the beta of Facebook in Python. As for the market benchmark, we utilize SPY. In a follow-up post, we will present calculation of stock beta in Excel.

Beta of an investment is a measure of the risk arising from exposure to general market movements as opposed to idiosyncratic factors.

The market portfolio of all investable assets has a beta of exactly 1. A beta below 1 can indicate either an investment with lower volatility than the market, or a volatile investment whose price movements are not highly correlated with the market. An example of the first is a treasury bill: the price does not fluctuate significantly, so it has a low beta. An example of the second is gold. The price of gold fluctuates significantly, but not in the same direction or at the same time as the market.

A beta greater than 1 generally means that the asset both is volatile and tends to move up and down with the market. An example is a stock in a big technology company. Negative betas are possible for investments that tend to go down when the market goes up, and vice versa. There are few fundamental investments with consistent and significant negative betas, but some derivatives like put options can have large negative betas. Read more

Formula for equity (stock) beta

The beta of a financial instrument is calculated as follows,

Quantitative analysis of stock beta

where

  • rS is the stock return,
  • rM is the market return,
  • Cov denotes the return covariance and,
  • Var denotes the return variance.

Calculating Stock Beta in Python

We downloaded 5 years of data from Yahoo Finance and implemented equation (1) in Python.  The picture below shows the result returned by the Python program

How to calculate stock beta

It’s observed that the beta of Facebook, a technology stock, is 1.19, which means that Facebook is more volatile than the market.

The next picture shows the stock returns regressed against market returns. Note that the slope of the linear regression line equals the beta of the stock.

Quantitative trading using beta in python

Further questions

What's your question? Ask it in the discussion forum

Have an answer to the questions below? Post it here or in the forum

LATEST NEWSInvestor group bans carbon removal from CO2 reduction plans
Investor group bans carbon removal from CO2 reduction plans

LONDON — An investor group committed to climate change and controlling $11 trillion in assets has banned members from counting carbon removal schemes towards their emissions reduction targets before 2030, amid increasing scrutiny of the fast-growing market for carbon offsets. The Net Zero Asset Owner…

Stay up-to-date with the latest news - click here
LATEST NEWSUK grocery price inflation rises to record 16.7% -Kantar
UK grocery price inflation rises to record 16.7% -Kantar

LONDON — British grocery inflation hit a record 16.7% in the four weeks to Jan. 22, dealing another blow to consumers battling an escalating cost-of-living crisis, industry data showed on Tuesday. Market researcher Kantar said grocery inflation was at its highest since it started tracking…

Stay up-to-date with the latest news - click here
LATEST NEWSFrance eked out 0.1% growth in Q4 as energy crisis eased
France eked out 0.1% growth in Q4 as energy crisis eased

PARIS — France managed to eke out meager growth in the final quarter of 2022 as falling energy imports and firm business investment offset a pullback in consumer spending, preliminary gross domestic product (GDP) figures released on Tuesday showed. The euro zone’s second-biggest economy grew…

Stay up-to-date with the latest news - click here
LATEST NEWSAegir Insights Welcomes Ørsted as a Client for its Offshore Wind Market Intelligence and Investment Analytics
Aegir Insights Welcomes Ørsted as a Client for its Offshore Wind Market Intelligence and Investment Analytics

COPENHAGEN, Denmark — Aegir Insights, a sector leader in offshore wind intelligence and investment solutions, is proud to welcome Ørsted A/S (Ørsted), the world’s largest offshore wind developer, as a client. Aegir Insights provides a competitive edge to offshore wind investors by combining deep industry…

Stay up-to-date with the latest news - click here
LATEST NEWSBlack Friday, holiday sales spur demand at South Africa's Shoprite
Black Friday, holiday sales spur demand at South Africa's Shoprite
Stay up-to-date with the latest news - click here

Leave a Reply