diff --git a/database_caller.py b/database_caller.py index b4c2c24..aa14f14 100755 --- a/database_caller.py +++ b/database_caller.py @@ -183,6 +183,7 @@ def updateStocks(api_key, logf): json.dump(all_stocks_settings, f) elif 'query1.finance.yahoo.com/v7' in url: + url = url.replace('BRK.A', 'BRK-A').replace('BRK.B', 'BRK-B') response = requests.get(url, headers=headers) data = response.json() if "'error': {'code'" in str(data): @@ -212,7 +213,7 @@ def updateStocks(api_key, logf): for symbol in symbols: for stock in data['quoteResponse']['result']: if stock['symbol'] == symbol: - stock_info[stock['symbol']] = {'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']} all_stocks_settings['symbols'] = stock_info with open('csv/stocks_settings.json', 'w+') as f: