Skip to content
Related Articles

Related Articles

Introduction to NSE Tools Module in Python
  • Last Updated : 18 Aug, 2020

NSE National Stock Exchange of India Limited is the leading stock exchange of India, located in Mumbai, Maharashtra. NSE was established in 1992 as the first dematerialized electronic exchange in the country.

nsetools is a library for collecting real time data from National Stock Exchange of India. It can be used in various types of projects which requires fetching live quotes for a given stock or index or building large data sets for further data analytics. We can also build command line interface applications which can provide us live market details at a blazing fast speeds, much faster than any browser. The accuracy of data is only as correct as provided on http://www.nseindia.com

In order to install nse tools we have to use the command given below

pip install nsetools

Creating a Nse object




# importing nse from nse tools
from nsetools import Nse
  
# creating a Nse object
nse = Nse()
  
# printing Nse object
print(nse)

Output :



Driver Class for National Stock Exchange (NSE)

Getting Information




# importing nse from nse tools
from nsetools import Nse
  
# creating a Nse object
nse = Nse()
  
# getting quote of the sbin
quote = nse.get_quote('sbin')
  
# printing comapny name
print(quote['companyName'])
  
# printing buy price
print("Buy Price : " + str(quote['buyPrice1']))

Output :

State Bank of India
Buy Price : 191.45




# importing nse from nse tools
from nsetools import Nse
  
# creating a Nse object
nse = Nse()
  
# getting quote of the sbin
quote = nse.get_quote('sbin')
  
# printing comapny name
print(quote['companyName'])
  
# printing average price
print("Average Price : " + str(quote['averagePrice']))

Output :

State Bank of India
Average Price : 193.9

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :