We can use the nsepython library to fetch data from the NSE website. Steps to install NSEPython:

In any Python ide, for ex- pycharm type the following code in the terminal:

  • $pip install nsepython
  • To upgrade to the latest version,
  • pip install --upgrade nsepython

This will install the module nsepython.

To print the Indices we use the following code in the console window:

  • from nsepython import *
  • print(indices)

To get the lastest Nifty/Banknifty traded price:

index = (nse_index())
j=index[index.indexName == 'NIFTY BANK']
y = j['last'].values[0]
y = y.replace(',', '')
y = int(float(y))
print("\nNifty bank LTP: " + str(y))

The output will look something like this:

Leave a Reply