From 62e30970de2aff47f4a920d8df9b81ce834f150c Mon Sep 17 00:00:00 2001 From: Justin Date: Wed, 29 Mar 2023 17:41:33 +0800 Subject: [PATCH] Update database_caller.py --- database_caller.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/database_caller.py b/database_caller.py index b66b10d..4903899 100755 --- a/database_caller.py +++ b/database_caller.py @@ -148,9 +148,14 @@ def updateStocksPrePost(api_key, logf): 'prechange': '%.2f' % stock['preMarketChange'], 'prepercent': '%.2f' % stock['preMarketChangePercent']} except: - stock_info[stock['symbol']]['Pre-market'] = {'preprice': '%.2f' % stock['regularMarketPrice'], - 'prechange': '%.2f' % 0, - 'prepercent': '%.2f' % 0} + try: + stock_info[stock['symbol']]['Pre-market'] = {'preprice': '%.2f' % stock['postMarketPrice'], + 'prechange': '%.2f' % 0, + 'prepercent': '%.2f' % 0} + except: + stock_info[stock['symbol']]['Pre-market'] = {'preprice': '%.2f' % stock['regularMarketPrice'], + 'prechange': '%.2f' % 0, + 'prepercent': '%.2f' % 0} try: stock_info[stock['symbol']]['Post-market'] = {'postprice': '%.2f' % stock['postMarketPrice'], 'postchange': '%.2f' % stock['postMarketChange'],