added try and except for prepost

This commit is contained in:
Justin 2023-07-24 17:32:07 +08:00 committed by GitHub
parent e26f27eb38
commit 39f0496b92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -282,6 +282,7 @@ def updateStocksPrePost(api_key, logf):
if len(prepost_data) > 0:
for symbol in symbols:
try:
for stock in prepost_data:
if stock['symbol'] == symbol:
stock_info[stock['symbol']] = {"time_now":time_now}
@ -306,7 +307,8 @@ def updateStocksPrePost(api_key, logf):
stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')]['Post-market'] = {'postprice': '%.2f' % stock['regularMarketPrice'],
'postchange': '%.2f' % 0,
'postpercent': '%.2f' % 0}
except:
pass
all_stocks_settings['symbols'] = stock_info
with open('csv/prepost_settings.json', 'w+') as f: