try replacing brk a brk b for yfinance
This commit is contained in:
parent
7ce1c8973b
commit
8e7d19b2a0
@ -183,6 +183,7 @@ def updateStocks(api_key, logf):
|
|||||||
json.dump(all_stocks_settings, f)
|
json.dump(all_stocks_settings, f)
|
||||||
|
|
||||||
elif 'query1.finance.yahoo.com/v7' in url:
|
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)
|
response = requests.get(url, headers=headers)
|
||||||
data = response.json()
|
data = response.json()
|
||||||
if "'error': {'code'" in str(data):
|
if "'error': {'code'" in str(data):
|
||||||
@ -212,7 +213,7 @@ def updateStocks(api_key, logf):
|
|||||||
for symbol in symbols:
|
for symbol in symbols:
|
||||||
for stock in data['quoteResponse']['result']:
|
for stock in data['quoteResponse']['result']:
|
||||||
if stock['symbol'] == symbol:
|
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
|
all_stocks_settings['symbols'] = stock_info
|
||||||
with open('csv/stocks_settings.json', 'w+') as f:
|
with open('csv/stocks_settings.json', 'w+') as f:
|
||||||
|
Loading…
Reference in New Issue
Block a user