fixed ordering bug

This commit is contained in:
Neythen Treloar 2022-03-01 18:37:41 +00:00
parent d891e5ef6d
commit 4c16217584

View File

@ -72,7 +72,9 @@ def updateStocks(api_key):
stock_info = {}
if len(data) > 0:
for symbol in symbols:
for stock in data:
if stock['symbol'] == symbol:
stock_info[stock['symbol']] = {'current': stock['price'], 'change': stock['change_since'], 'percent_change':stock['percent']}
print(stock_info)
@ -125,11 +127,14 @@ def updateCrypto(api_key):
coin_info = {}
if len(data) > 0:
for sb in symbol_base:
for i,d in enumerate(data):
symbol = d['symbol']
base = d['currency']
if symbol.upper() + ',' + base.upper() == sb:
coin_info[symbol.upper() + ',' + base.upper()] = {'current': d['price'], '24hr_change': d['price_over_24hr'], 'percent_change': d['percent_over_24hr']}
all_crypto_settings['symbols'] = coin_info
@ -180,9 +185,9 @@ def updateForex(api_key):
if len(data) > 0:
print(data)
c_dict = {}
for sb in symbol_base:
for d in data:
if d['uid'].replace('/',',') == sb:
c_dict[d['uid'].replace('/',',')] = {'current': d['rate'], '24hr_change': d['rate_over_24hr'], 'percent_change':d['percent_over_24hr']}