swapniljariwala / nsepy

Python Library to get publicly available data on NSE website ie. stock quotes, historical data, live indices
https://nsepy-xyz.web.app
Other
758 stars 377 forks source link

Update constants.py #226

Closed kanishk619 closed 2 years ago

kanishk619 commented 2 years ago

The symbols count constant is pretty old due to which get_history fails for few symbols which exists but count value is outdated. For example for IRB If someone wants to always keep the constants updated, you could do something like below

def update_nsepy_constants(): """ This function patches the constants variable in nsepy which contains old symbol counts """ from nsepy.constants import symbol_count, symbol_list database_counts = dict(NSESymbolCount.objects.all().values_list()) for symbol in database_counts: try: symbol_count[symbol] = database_counts[symbol] except KeyError: pass symbol_list = symbol_count.keys()

Just call the update_nsepy_constants before calling any nsepy function