try except failsafe for ipo

This commit is contained in:
Justin 2023-03-08 15:47:31 +08:00 committed by GitHub
parent 3ae2e82d44
commit 3563daf9a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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