From 98ee21b78dc83063aebd7c275d21302a76bc76bd Mon Sep 17 00:00:00 2001 From: Justin Date: Thu, 3 Aug 2023 16:43:31 +0800 Subject: [PATCH] added volume, day high and day low --- database_caller.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/database_caller.py b/database_caller.py index 9c359cc..f9a93f4 100755 --- a/database_caller.py +++ b/database_caller.py @@ -163,7 +163,7 @@ def updateStocks(api_key, logf): 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'} # url = 'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/stocks?symbols=' - url1 = 'https://query1.finance.yahoo.com/v7/finance/quote?fields=regularMarketPrice,regularMarketChangePercent,regularMarketChange®ion=US&lang=en-US&symbols=' + url1 = 'https://query1.finance.yahoo.com/v7/finance/quote?fields=regularMarketPrice,regularMarketChangePercent,regularMarketChange,regularMarketDayHigh,regularMarketDayLow,regularMarketVolume®ion=US&lang=en-US&symbols=' url2 = 'https://cloud.iexapis.com/v1/stock/market/batch?&types=quote&token=pk_aff870df1a984daa9dd43c71801c1936&symbols=' url = random.choice([url1, url2]) @@ -177,7 +177,7 @@ def updateStocks(api_key, logf): if len(data) > 0: for symbol in symbols: try: - stock_info[data[symbol]['quote']['symbol']] = {'current': data[symbol]['quote']['latestPrice'], 'change': data[symbol]['quote']['change'], 'percent_change':data[symbol]['quote']['changePercent'] * 100} + stock_info[data[symbol]['quote']['symbol']] = {'current': data[symbol]['quote']['latestPrice'], 'change': data[symbol]['quote']['change'], 'percent_change':data[symbol]['quote']['changePercent'] * 100, 'day_low':data[symbol]['low'], 'day_high':data[symbol]['high'], 'volume':data[symbol]['latestVolume']} except: pass all_stocks_settings['symbols'] = stock_info @@ -216,7 +216,7 @@ def updateStocks(api_key, logf): try: for stock in data['quoteResponse']['result']: if stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B') == symbol: - stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')] = {'current': stock['regularMarketPrice'], 'change': stock['regularMarketChange'], 'percent_change':stock['regularMarketChangePercent']} + stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')] = {'current': stock['regularMarketPrice'], 'change': stock['regularMarketChange'], 'percent_change':stock['regularMarketChangePercent'], 'day_low': stock['regularMarketDayLow'], 'day_high': stock['regularMarketDayHigh'], 'volume': stock['regularMarketVolume']} except: pass all_stocks_settings['symbols'] = stock_info