Monday, 13 March 2023

Python Stock : NSE

 Introduction to NSE Tools Module in Python

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. 


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

pip install nsetools

Creating a NSE object and Using

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

# Driver Class for National Stock Exchange (NSE)

# getting quote of the sbin
quote = nse.get_quote('sbin')
q1 = nse.get_quote('TATAMOTORS')
# printing company name
print(quote['companyName'])
 
# printing buy price
print("Buy Price : " + str(quote['buyPrice1']))
print("SBIN open : " + str(quote['open']))


print(q1['companyName'])
print("Tata Motors Open : " + str(q1['open']))

Driver Class for National Stock Exchange (NSE)
State Bank of India
Buy Price : None
SBIN open  : 547.0
Tata Motors Limited
Tata Motors Open : 436.1


print(q1)
"""

{'pricebandupper': 479.4, 'symbol': 'TATAMOTORS', 'applicableMargin': 18.43, 'bcEndDate': '09-AUG-16', 'totalSellQuantity': None, 'adhocMargin': None, 'companyName': 'Tata Motors Limited', 'marketType': 'N',
'exDate': '18-JUL-16', 'bcStartDate': '20-JUL-16', 'css_status_desc': 'Listed', 'dayHigh': 437.0, 'basePrice': 435.85, 'securityVar': 14.93, 'pricebandlower': 392.3, 'sellQuantity5': None, 'sellQuantity4': None, 'sellQuantity3': None, 'cm_adj_high_dt': '17-AUG-22', 'sellQuantity2': None, 'dayLow': 419.1, 'sellQuantity1': None, 'quantityTraded': 8780169.0, 'pChange': '-2.93', 'totalTradedValue': 37481.66, 'deliveryToTradedQuantity': 36.45, 'totalBuyQuantity': 2567.0, 'averagePrice': 426.89, 'indexVar': None, 'cm_ffm': 75757.3, 'purpose': 'DIVIDEND - RE 0.20/- PER SHARE', 'buyPrice2': None, 'secDate': '13-Mar-2023 00:00:00', 'buyPrice1': 422.4, 'high52': 494.4, 'previousClose': 435.85, 'ndEndDate': None, 'low52': 366.2,
'buyPrice4': None, 'buyPrice3': None, 'recordDate':
None, 'deliveryQuantity': 3200108.0, 'buyPrice5': None, 'priceBand': 'No Band', 'extremeLossMargin': 3.5, 'cm_adj_low_dt': '12-MAY-22', 'varMargin': 14.93,
'sellPrice1': None, 'sellPrice2': None, 'totalTradedVolume': 8780169.0, 'sellPrice3': None, 'sellPrice4': None, 'sellPrice5': None, 'change': '-12.75', 'surv_indicator': None, 'ndStartDate': None, 'buyQuantity4': None, 'isExDateFlag': False, 'buyQuantity3': None, 'buyQuantity2': None, 'buyQuantity1': 2567.0, 'series': 'EQ', 'faceValue': 2.0, 'buyQuantity5': None, 'closePrice': 422.4, 'open': 436.1, 'isinCode': 'INE155A01022', 'lastPrice': 423.1} """


No comments:

Post a Comment

Making Prompts for Profile Web Site

  Prompt: Can you create prompt to craft better draft in a given topic. Response: Sure! Could you please specify the topic for which you...