Friday, September 10, 2021

Python for Indian Stock Market Analysis


Created on Sat Sep 11 10:14:16 2021

@author: Mann

"""


pip install nsetools

from nsetools import Nse

nse = Nse()

print (nse)


#Since it is a dictionary you can easily chop off fields of your interest.

q = nse.get_quote('infy') # it's ok to use both upper or lower case for codes.

from pprint import pprint # just for neatness of display

q['averagePrice']


pprint(q)

msft = nse.Ticker("infy")

# To get all listed indices 

nse.get_index_list()

nse.get_index_quote("nifty bank") # code can be provided in upper|lower case.

# List of Traded Stock Codes & Names

all_stock_codes = nse.get_stock_codes()

#This is a dictionary with more that thousand entries.


print (all_stock_codes)

#List of Index Codes Similar to above, there is a way to get the list of codes of all the traded indices. Unlike in previous section, the return type is list.

index_codes = nse.get_index_list()

pprint(index_codes)


9_Regular Expressions

Regular expressions- Sometimes in HTML, the developer defines more than one class name ( that’s class input has more than one name Here ...