diff --git a/database_caller.py b/database_caller.py index ae4fa5e..26e938c 100755 --- a/database_caller.py +++ b/database_caller.py @@ -314,29 +314,32 @@ def updateIpo(api_key, logf): ipo_list = [] - if len(all_ipo['ipoCalendar']) > 0: - for ipo in all_ipo['ipoCalendar']: - try: - shares = human_format(ipo['numberOfShares']) - except: - shares = 'N/A' - try: - sharesvalue = human_format(ipo['totalSharesValue']) - except: - sharesvalue = 'N/A' + try: + if len(all_ipo['ipoCalendar']) > 0: + for ipo in all_ipo['ipoCalendar']: + try: + shares = human_format(ipo['numberOfShares']) + except: + shares = 'N/A' + try: + sharesvalue = human_format(ipo['totalSharesValue']) + except: + sharesvalue = 'N/A' - ipo_list.append({ - 'date':ipo['date'], - 'name':ipo['name'], - 'shares':shares, - 'price':ipo['price'], - 'status':ipo['status'], - 'symbol':ipo['symbol'], - 'sharesvalue':sharesvalue - }) - else: + ipo_list.append({ + 'date':ipo['date'], + 'name':ipo['name'], + 'shares':shares, + 'price':ipo['price'], + 'status':ipo['status'], + 'symbol':ipo['symbol'], + 'sharesvalue':sharesvalue + }) + else: + ipo_list = ['No Data'] + except: ipo_list = ['No Data'] - + ipo_settings['symbols'] = ipo_list f = open('csv/ipo_settings.json', 'w+') json.dump(ipo_settings, f)