fixed ordering bug
This commit is contained in:
parent
d891e5ef6d
commit
4c16217584
@ -72,12 +72,14 @@ def updateStocks(api_key):
|
|||||||
|
|
||||||
stock_info = {}
|
stock_info = {}
|
||||||
if len(data) > 0:
|
if len(data) > 0:
|
||||||
for stock in data:
|
for symbol in symbols:
|
||||||
stock_info[stock['symbol']] = {'current': stock['price'], 'change': stock['change_since'], 'percent_change':stock['percent']}
|
for stock in data:
|
||||||
|
if stock['symbol'] == symbol:
|
||||||
print(stock_info)
|
stock_info[stock['symbol']] = {'current': stock['price'], 'change': stock['change_since'], 'percent_change':stock['percent']}
|
||||||
|
|
||||||
|
print(stock_info)
|
||||||
all_stocks_settings['symbols'] = stock_info
|
all_stocks_settings['symbols'] = stock_info
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
json.dump(all_stocks_settings, open('csv/stocks_settings.json', 'w+'))
|
json.dump(all_stocks_settings, open('csv/stocks_settings.json', 'w+'))
|
||||||
@ -125,13 +127,16 @@ def updateCrypto(api_key):
|
|||||||
|
|
||||||
coin_info = {}
|
coin_info = {}
|
||||||
if len(data) > 0:
|
if len(data) > 0:
|
||||||
for i,d in enumerate(data):
|
for sb in symbol_base:
|
||||||
|
for i,d in enumerate(data):
|
||||||
symbol = d['symbol']
|
|
||||||
base = d['currency']
|
symbol = d['symbol']
|
||||||
|
base = d['currency']
|
||||||
coin_info[symbol.upper() + ',' + base.upper()] = {'current': d['price'], '24hr_change': d['price_over_24hr'], 'percent_change': d['percent_over_24hr']}
|
|
||||||
|
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
|
all_crypto_settings['symbols'] = coin_info
|
||||||
|
|
||||||
json.dump(all_crypto_settings, open('csv/crypto_settings.json', 'w+'))
|
json.dump(all_crypto_settings, open('csv/crypto_settings.json', 'w+'))
|
||||||
@ -180,10 +185,10 @@ def updateForex(api_key):
|
|||||||
if len(data) > 0:
|
if len(data) > 0:
|
||||||
print(data)
|
print(data)
|
||||||
c_dict = {}
|
c_dict = {}
|
||||||
|
for sb in symbol_base:
|
||||||
for d in data:
|
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']}
|
c_dict[d['uid'].replace('/',',')] = {'current': d['rate'], '24hr_change': d['rate_over_24hr'], 'percent_change':d['percent_over_24hr']}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user