Member-only story

How to find the beta of Indian stocks using Python?

Amit Kumar Ghosh
4 min readAug 29, 2023

--

Beta is a coefficient is a measure of its volatility over time compared to a market benchmark. The market benchmark has a beta of 1. Shortly, if volatility is 1.5 it means it is 50% more volatile than the market.

  • A stock that swings more than the market over time has a beta greater than 1.0.
  • If a stock moves less than the market, the stock’s beta is less than 1.0.

Finding the beta of a stock using the formula

  • Get the Historical Price of the Stock or Index.
  • Get the Historical Price of the other Stock or Index against which You are trying to benchmark.
  • Calculate the Percentage Change for the same period for both the stock/index and the benchmark.
  • Calculate the covariance of the stock/index to the benchmark.
  • Calculate the Variance of the benchmark.

Now,

Beta = Covariance/Variance

In simple terms,

  • Covariance is the measure of a stock/index’s return relative to the market.
  • Variance is the measure of how the market moves relative to its mean.

Python Code

This Python code patch is written for the NSEPython Library first time. We shall use Daily as period and NIFTY 50 as default benchmark.

Part 1 — Get the…

--

--

Amit Kumar Ghosh
Amit Kumar Ghosh

Written by Amit Kumar Ghosh

Aloha, I’m Amit Ghosh, a web entrepreneur and avid blogger. Bitten by entrepreneurial bug, I got kicked out from college and ended up being millionaire!

No responses yet