Sunday, November 17, 2024
Google search engine
HomeLanguagesNseTools – Getting Stock Quote of Given Company

NseTools – Getting Stock Quote of Given Company

In this article we will see how we can get the stock quote of given company using nsetools. Nsetools is a library for collecting real time data from National Stock Exchange of India. A stock quote is the price of a stock as quoted on an exchange. A basic quote for a specific stock provides information, such as its bid and ask price, last traded price, and volume traded.

Steps to get the Stock Quote
1. Import the Nse from nsetools
2. Create a Nse object
3. From the Nse object get the stock quote with the help of get_quote method with the NSE Stock code of the company
4. Print the stock quote

Below is the implementation




# importing nse from nse tools
from nsetools import Nse
  
# creating a Nse object
nse = Nse()
  
# nse stock code for wipro
code = "wipro"
  
# getting stock quote 
quote = nse.get_quote(code)
  
# printing quote
print(quote)


Output :

{'pricebandupper': 309.15, 'symbol': 'WIPRO', 'applicableMargin': 19.23, 'bcEndDate': '13-JUL-20', 'totalSellQuantity': None, 'adhocMargin': None, 'companyName': 'Wipro Limited', 'marketType': 'N', 'exDate': '08-JUL-20', 'bcStartDate': '10-JUL-20', 'css_status_desc': 'Listed', 'dayHigh': 284.45, 'basePrice': 281.05, 'securityVar': 15.73, 'pricebandlower': 252.95, 'sellQuantity5': None, 'sellQuantity4': None, 'sellQuantity3': None, 'cm_adj_high_dt': '31-JUL-20', 'sellQuantity2': None, 'dayLow': 277.4, 'sellQuantity1': None, 'quantityTraded': 7345555.0, 'pChange': '-1.05', 'totalTradedValue': 20596.94, 'deliveryToTradedQuantity': 21.36, 'totalBuyQuantity': 610.0, 'averagePrice': 280.4, 'indexVar': None, 'cm_ffm': 41333.68, 'purpose': 'ANNUAL GENERAL MEETING', 'buyPrice2': None, 'secDate': '05-Aug-2020 00:00:00', 'buyPrice1': 278.2, 'high52': 290.8, 'previousClose': 281.05, 'ndEndDate': None, 'low52': 159.4, 'buyPrice4': None, 'buyPrice3': None, 'recordDate': None, 'deliveryQuantity': 1569237.0, 'buyPrice5': None, 'priceBand': 'No Band', 'extremeLossMargin': 3.5, 'cm_adj_low_dt': '19-MAR-20', 'varMargin': 15.73, 'sellPrice1': None, 'sellPrice2': None, 'totalTradedVolume': 7345555.0, 'sellPrice3': None, 'sellPrice4': None, 'sellPrice5': None, 'change': '-2.95', 'surv_indicator': None, 'ndStartDate': None, 'buyQuantity4': None, 'isExDateFlag': False, 'buyQuantity3': None, 'buyQuantity2': None, 'buyQuantity1': 610.0, 'series': 'EQ', 'faceValue': 2.0, 'buyQuantity5': None, 'closePrice': 278.2, 'open': 281.25, 'isinCode': 'INE075A01022', 'lastPrice': 278.1}

Another example




# importing nse from nse tools
from nsetools import Nse
  
# creating a Nse object
nse = Nse()
  
# nse stock code for hdfc
code = "hdfcbank"
  
# getting stock quote 
quote = nse.get_quote(code)
  
# printing quote
print(quote)


Output :

{'pricebandupper': 1145.8, 'symbol': 'HDFCBANK', 'applicableMargin': 18.2, 'bcEndDate': None, 'totalSellQuantity': None, 'adhocMargin': None, 'companyName': 'HDFC Bank Limited', 'marketType': 'N', 'exDate': '19-SEP-19', 'bcStartDate': None, 'css_status_desc': 'Listed', 'dayHigh': 1055.8, 'basePrice': 1041.65, 'securityVar': 14.7, 'pricebandlower': 937.5, 'sellQuantity5': None, 'sellQuantity4': None, 'sellQuantity3': None, 'cm_adj_high_dt': '19-DEC-19', 'sellQuantity2': None, 'dayLow': 1020.0, 'sellQuantity1': None, 'quantityTraded': 16610696.0, 'pChange': '-1.03', 'totalTradedValue': 172025.35, 'deliveryToTradedQuantity': 26.31, 'totalBuyQuantity': 7009.0, 'averagePrice': 1035.63, 'indexVar': None, 'cm_ffm': 445360.08, 'purpose': 'FACE VALUE SPLIT (SUB-DIVISION) - FROM RS 2 PER SHARE TO RS 1 PER SHARE', 'buyPrice2': None, 'secDate': '05-Aug-2020 00:00:00', 'buyPrice1': 1027.55, 'high52': 1305.5, 'previousClose': 1041.65, 'ndEndDate': None, 'low52': 738.75, 'buyPrice4': None, 'buyPrice3': None, 'recordDate': '20-SEP-19', 'deliveryQuantity': 4369897.0, 'buyPrice5': None, 'priceBand': 'No Band', 'extremeLossMargin': 3.5, 'cm_adj_low_dt': '24-MAR-20', 'varMargin': 14.7, 'sellPrice1': None, 'sellPrice2': None, 'totalTradedVolume': 16610696.0, 'sellPrice3': None, 'sellPrice4': None, 'sellPrice5': None, 'change': '-10.70', 'surv_indicator': None, 'ndStartDate': None, 'buyQuantity4': None, 'isExDateFlag': False, 'buyQuantity3': None, 'buyQuantity2': None, 'buyQuantity1': 7009.0, 'series': 'EQ', 'faceValue': 1.0, 'buyQuantity5': None, 'closePrice': 1027.55, 'open': 1047.95, 'isinCode': 'INE040A01034', 'lastPrice': 1030.95}

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments