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
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