added try and except for prepost
This commit is contained in:
parent
e26f27eb38
commit
39f0496b92
@ -282,31 +282,33 @@ def updateStocksPrePost(api_key, logf):
|
|||||||
|
|
||||||
if len(prepost_data) > 0:
|
if len(prepost_data) > 0:
|
||||||
for symbol in symbols:
|
for symbol in symbols:
|
||||||
for stock in prepost_data:
|
try:
|
||||||
if stock['symbol'] == symbol:
|
for stock in prepost_data:
|
||||||
stock_info[stock['symbol']] = {"time_now":time_now}
|
if stock['symbol'] == symbol:
|
||||||
try:
|
stock_info[stock['symbol']] = {"time_now":time_now}
|
||||||
stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')]['Pre-market'] = {'preprice': '%.2f' % stock['preMarketPrice'],
|
try:
|
||||||
|
stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')]['Pre-market'] = {'preprice': '%.2f' % stock['preMarketPrice'],
|
||||||
'prechange': '%.2f' % stock['preMarketChange'],
|
'prechange': '%.2f' % stock['preMarketChange'],
|
||||||
'prepercent': '%.2f' % stock['preMarketChangePercent']}
|
'prepercent': '%.2f' % stock['preMarketChangePercent']}
|
||||||
except:
|
except:
|
||||||
try:
|
try:
|
||||||
stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')]['Pre-market'] = {'preprice': '%.2f' % stock['postMarketPrice'],
|
stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')]['Pre-market'] = {'preprice': '%.2f' % stock['postMarketPrice'],
|
||||||
'prechange': '%.2f' % 0,
|
'prechange': '%.2f' % 0,
|
||||||
'prepercent': '%.2f' % 0}
|
'prepercent': '%.2f' % 0}
|
||||||
except:
|
except:
|
||||||
stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')]['Pre-market'] = {'preprice': '%.2f' % stock['regularMarketPrice'],
|
stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')]['Pre-market'] = {'preprice': '%.2f' % stock['regularMarketPrice'],
|
||||||
'prechange': '%.2f' % 0,
|
'prechange': '%.2f' % 0,
|
||||||
'prepercent': '%.2f' % 0}
|
'prepercent': '%.2f' % 0}
|
||||||
try:
|
try:
|
||||||
stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')]['Post-market'] = {'postprice': '%.2f' % stock['postMarketPrice'],
|
stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')]['Post-market'] = {'postprice': '%.2f' % stock['postMarketPrice'],
|
||||||
'postchange': '%.2f' % stock['postMarketChange'],
|
'postchange': '%.2f' % stock['postMarketChange'],
|
||||||
'postpercent': '%.2f' % stock['postMarketChangePercent']}
|
'postpercent': '%.2f' % stock['postMarketChangePercent']}
|
||||||
except:
|
except:
|
||||||
stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')]['Post-market'] = {'postprice': '%.2f' % stock['regularMarketPrice'],
|
stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')]['Post-market'] = {'postprice': '%.2f' % stock['regularMarketPrice'],
|
||||||
'postchange': '%.2f' % 0,
|
'postchange': '%.2f' % 0,
|
||||||
'postpercent': '%.2f' % 0}
|
'postpercent': '%.2f' % 0}
|
||||||
|
except:
|
||||||
|
pass
|
||||||
all_stocks_settings['symbols'] = stock_info
|
all_stocks_settings['symbols'] = stock_info
|
||||||
|
|
||||||
with open('csv/prepost_settings.json', 'w+') as f:
|
with open('csv/prepost_settings.json', 'w+') as f:
|
||||||
|
Loading…
Reference in New Issue
Block a user