How to calculate NIFTY 50 value from the stock prices in Python

Amit Kumar Ghosh
3 min readSep 25, 2023

Calculating The NIFTY Index

In this discussion, We will attempt to calculate the NIFTY Index in program directly from the stock prices. Till date, there has been many attempt to calculate the NIFTY index by various programmers but it all ended in non conclusive discussions because of lack of clarity.

As We are aiming the impossible, Keep an open mind and think this as a constructive discussion rather than some validated assertion.

Section I

Here is a snapshot of NIFTY as we are discussing. This image will act as a good reference point.

Lets refer to this document — NIFTY 50 Methodology

In this document shared, in the page 11, You can see this formula –

  • Free Float Market Capitalization = Shares outstanding * Price * IWF
  • Index Value = Current Market Value / Base Market Capital * Base Index Value (1000)

Also, in the Page 6, it is written that the Base capital was 2.06 trillion.

df["free_float_market_cap"] = df['sharesOutstanding']*df['ltP']*df['investableWeightFactor']
net_free_float_market_cap =df["free_float_market_cap"].sum()
net_free_float_market_cap/2060000000000 * 1000

--

--

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!