This commit is contained in:
Justin 2023-09-07 18:08:58 +08:00 committed by GitHub
parent 72be8d4a9e
commit d85d58455e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -190,7 +190,7 @@ def updateStocks(api_key, logf):
if 'name' in stock_info[data[symbol]['quote']['symbol']] and stock_info[data[symbol]['quote']['symbol']]['name'] != '':
stock_info[data[symbol]['quote']['symbol']] = {'current': str(data[symbol]['quote']['latestPrice']), 'change': str(data[symbol]['quote']['change']), 'percent_change': str(data[symbol]['quote']['changePercent'] * 100), 'day_low': str(data[symbol]['quote']['low']), 'day_high': str(data[symbol]['quote']['high']), 'volume': str(human_format(data[symbol]['quote']['latestVolume'])), 'name': stock_info[data[symbol]['quote']['symbol']]['name']}
else:
stock_info[data[symbol]['quote']['symbol']] = {'current': str(data[symbol]['quote']['latestPrice']), 'change': str(data[symbol]['quote']['change']), 'percent_change': str(data[symbol]['quote']['changePercent'] * 100), 'day_low': str(data[symbol]['quote']['low']), 'day_high': str(data[symbol]['quote']['high']), 'volume': str(human_format(data[symbol]['quote']['latestVolume'])), 'name': data[symbol]['quote']['companyName']}
stock_info[data[symbol]['quote']['symbol']] = {'current': str(data[symbol]['quote']['latestPrice']), 'change': str(data[symbol]['quote']['change']), 'percent_change': str(data[symbol]['quote']['changePercent'] * 100), 'day_low': str(data[symbol]['quote']['low']), 'day_high': str(data[symbol]['quote']['high']), 'volume': str(human_format(data[symbol]['quote']['latestVolume'])), 'name': data[symbol]['quote']['companyName'].split(' - ')[0]}
except:
pass
all_stocks_settings['symbols'] = stock_info
@ -230,7 +230,7 @@ def updateStocks(api_key, logf):
for stock in data['quoteResponse']['result']:
if stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B') == symbol and 'name' in stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')] and stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')]['name'] != '':
stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')] = {'current': str(stock['regularMarketPrice']), 'change': str(stock['regularMarketChange']), 'percent_change': str(stock['regularMarketChangePercent']), 'day_low': str(stock['regularMarketDayLow']), 'day_high': str(stock['regularMarketDayHigh']), 'volume': str(human_format(stock['regularMarketVolume'])), 'name': stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')]['name']}
else:
elif stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B') == symbol and 'name' not in stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')]:
stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')] = {'current': str(stock['regularMarketPrice']), 'change': str(stock['regularMarketChange']), 'percent_change': str(stock['regularMarketChangePercent']), 'day_low': str(stock['regularMarketDayLow']), 'day_high': str(stock['regularMarketDayHigh']), 'volume': str(human_format(stock['regularMarketVolume'])), 'name': stock['longName'].replace(',','')}
except:
pass