×

NSE Tools In Python

About NSE

NSE (National Stock Exchange) of India Limited is the advanced stock exchange of India. It is located in Mumbai, Maharastra and It was organized in 1992. It was organized as the first dematerialized electronic exchange in the country.

The nsetools is defined as the library that is used for getting real-time data from the National Stock Exchange of India. It is used in different kinds of projects which need to fetches live quotes for a specific stock or indexes and developing large data sets for performing data analytics.

Command-line interface applications can be also built for providing the live market details at a very fast speed and it can be much faster than any browser. The data accuracy is perfect as provided on http://www.nseindia.com.

We can easily install nsetools by using the following command 

pip install nsetools

Example of creating a Nse object

In this example, we are creating a Nse object which returns the driver class for National Stock Exchange.

Example –

# import nse from nse tools

from nsetools import Nse

# Now, creating a Nse object

nse = Nse()

# printing the Nse object

print(nse)

Output:

Driver Class for National Stock Exchange (NSE)

Example of getting information of a company

Here, we are going to retrieve the information of a specific company and display the buying price of company shares.

# Code for getting information

# of company shares

# import nse from nse tools

from nsetools import Nse

# creating a Nse object

nse = Nse()

# getting quote of the HDFC

quote = nse.get_quote('hdfc')

# printing the name of company

print(quote['companyName'])

# printing the buying price of company shares

print("Buy Price : " + str(quote['buyPrice1']))

Output:

HDFC

Buy Price: 2818.10

Example of getting average trade price

We can also get the average price of any company. In this example we are trying to get the average share price of a company.

Example –

# Code for getting information

# of company shares

# import nse from nse tools

from nsetools import Nse

# creating a Nse object

nse = Nse()

# getting quote of the HDFC

quote = nse.get_quote('hdfc')

# printing company name

print(quote['companyName'])

# printing the average price of company shares

print("Average Price : " + str(quote['averagePrice']))

Output:

HDFC

Average Price: 2833.94

Conclusion

In the above article, we have studied the nsetools module in Python. Also, we have seen how to get the information of a company shares.


Related Topics

How to Program in Python on Raspberry pi?

Introduction to Python A popular programming tool with simple, complete novice syntax is Python structure of paragraphs, phrases, and words. Due to its widespread use, this has a large community that...

4 minutes read.

Python Dictionary

Dictionary in Python is an unordered collection of data values, which is used to store data values like a map. Unlike different data types that hold just individual assets as...

4 minutes read.

Python frozenset()

Python frozenset() class The frozenset() class in Python returns a new frozenset object, optionally with elements taken from iterable. Syntax class frozenset([iterable]) Parameter iterable: This parameter represents an iterable object, like list, set, tuple etc. Return This class returns an unchangeable...

1 minute read.

Python next() function

Python next() function The next() function in Python retrieves the next item from the iterator.  Syntax next(iterator[, default]) Parameter iterable: It is a required parameter which represents an iterable object. default: This parameter represents a default value to...

1 minute read.

Nested for Loop in Python

"Loop" is one of the foundation concepts to learn programming in any language. Nested loops are significant steps in solving many types of problems, ranging from basic to complex scenarios....

9 minutes read.

AX Contour in Python

Python Programming Language Python programming language is one of the most used programming languages, as it is used widely in the field of software and data analysis, web development, etc. It...

3 minutes read.

Best app for python

What is python? Python is a prevalent, general-purpose, and high-level programming language. Python Programming Language is appropriate for experienced programmers and also for beginners. Python programming language is being utilized by...

19 minutes read.

Cross Validation in Sklearn

Data scientists can benefit from cross-validation in machine learning in two key ways: it can assist in minimising the amount of data needed and ensure the artificial intelligence model is...

14 minutes read.

Method Overloading in Python

Overloading is a capability of a method and operator to behave differently according to the nature of parameters. Overloading is popular because it provides a good number of advantages: Reusability of code.Reduces...

3 minutes read.

How to build an Auto Clicker using Python?

What is an Auto Clicker? An Auto Clicker is software that is used for automating the click of a mouse on any particular element on the computer screen and controlling the...

8 minutes read.

Decision Tree Classification in Python

In this article, we will learn the implementation of the decision tree in Sklearn, which is nothing but the Scikit Learn library of python. First, we should learn what classification...

12 minutes read.

Python Project Ideas for Beginners

Python project ideas for beginners Advanced Python is an amazing platform to grow and achieve success as a developer in the future. Python is a programming language that can be very...

7 minutes read.

Python Infinity

Introduction We will discover how to define an infinite number in Python in this tutorial. Infinity, as we all know, is a value that cannot be defined and can either be...

5 minutes read.

How to upgrade PIP in python

We use the PIP command in our command prompt to install any package. PIP is used to install published Python packages in the PyPI (Python package index) or other indices....

3 minutes read.

How to read data from com port in python

Comport, the I/O interface is known as a COM port that allows the connection for a serial device to a computer. COM ports are sometimes referred to as serial ports....

3 minutes read.

Create First GUI Application using Tkinter in Python

GUI: A graphical interface (GUI) is a user interface that lets users interact with electronic devices like computers and smartphones by using menus, icons, and other visual cues (graphics). In contrast...

6 minutes read.

Python Typing Module

An Introduction to the Typing Module The typing module is introduced in Python version 3.5 and used to provide hinting method types in order to support static type checkers and linters...

10 minutes read.

Python String count() method

Python String count() method The string.count() method returns the number of times a specified value appears in the string. Syntax string.count(sub[, start[, end]]) Parameter sub: This parameter represents a substring to be searched. start: This parameter...

1 minute read.

Python String lstrip() method

Python String lstrip() method The string. lstrip () method in Python returns a copy of the string with leading characters removed (based on the string argument passed). Syntax string.lstrip([chars]) Parameter chars(optional): This parameter represents a...

1 minute read.

Fsolve in Python

Python Programming Language Python programming language is one of the most used programming languages, as it is used widely in the field of software and data analysis, web development, etc. It...

3 minutes read.