nsetools in PythonIn the following tutorial, we will discuss the nsetools library in the Python programming language. We will understand its features and work with some examples. So, let’s get started. Understanding the nsetools libraryNSE or National Stock Exchange of India Limited is the leading stock exchange of India, situated in Mumbai, Maharashtra. NSE was established in the year 1992 as the first dematerialized electronic exchange in the country. Python offers a library that allows the programmers to collect real-time data from National Stock Exchange (India). This library is known as nsetools. We can use this library in different projects, which requires fetching live quotes for a provided index or stock or creating large sets of data for further data analytics. We can also create Command-Line Interface (CLI) Applications that may deliver us the details of the live market at a blazing fast speed, pretty faster than any web browser. The data accuracy is only as correct as provided on the official website of the National Stock Exchange of India Limited. (http://www.nseindia.com) Main features of the Python nsetools librarySome of the key features of the Python nsetools library are stated as follows:
How to install the Python nsetools library?The installation part of the nsetools library is quite easy, and it has no external dependencies. All the dependencies of the library are part of standard distribution packages of Python. We can install the nsetools library using the pip installer as shown in the following syntax: Syntax: Updating the libraryIf some of us already have installed the nsetools library in their systems, then the following command will allow them to update the library. Syntax: Python 3 supportPython 3 support for the library has been included from version 1.0.0 and so on. Now, this library is able to work for both Python 2 as well as Python 3. Creating an NSE objectWe can create an NSE object using the Nse() function offered by the nsetools library. The same can be seen in the following example: Example: Output: NSE Object: Driver Class for National Stock Exchange (NSE) Explanation: In the above snippet of code, we have imported the required function from the library. We have then defined a variable that uses the Nse() function to create an NSE object. We have then printed the value of the variable for the users. Getting Information using the nsetools libraryLet us consider an example demonstrating the use of nsetools for gathering Information. Example: Output: State Bank of India Average Price: 431.97 Explanation: In the above snippet of code, we have imported the required module and created an NSE object using the Nse() function. We have then defined another variable that uses the get_quote() function on the NSE object to get the quotation of the specified company. We have then printed the required details for the users. |
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/263653.html