def get_all_stocks_data(start_index=None, count=-1): """ start_index and count can be used for downloading only a subset of data @start_index for @count number of stocks""" i = 0 for scrip in nse_get_all_stocks_list(start_index, count): time.sleep(random.randint(1, 5)) get_data_for_security(scrip.symbol, scrip.listing_date) # We downloaded. There might be some errors, we try this again global _failed while not _failed.empty(): s = _failed.get() if (s.errs > MAX_ERRS): print "Too many errors :", s.errs, \ "Hopelessly giving up on ", s.sym, s.start continue _do_get_data_for_security(s.sym, s.start, s.end, s.errs)
def get_all_stocks_data(start_index=None, count=-1): """ start_index and count can be used for downloading only a subset of data @start_index for @count number of stocks""" i = 0 for scrip in nse_get_all_stocks_list(start_index, count): time.sleep(random.randint(1,5)) get_data_for_security(scrip.symbol, scrip.listing_date) # We downloaded. There might be some errors, we try this again global _failed while not _failed.empty(): s = _failed.get() if (s.errs > MAX_ERRS): print "Too many errors :", s.errs, \ "Hopelessly giving up on ", s.sym, s.start continue _do_get_data_for_security(s.sym, s.start, s.end, s.errs)
def get_nse_stocks_dict(): nse_stocks_dict = {} # dictionary of nse stocks key = isin for nse_stock in nse_get_all_stocks_list(): nse_stocks_dict[nse_stock.isin] = nse_stock return nse_stocks_dict