added volume, day high and day low
This commit is contained in:
parent
caf38275ff
commit
98ee21b78d
@ -163,7 +163,7 @@ def updateStocks(api_key, logf):
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'}
|
||||
|
||||
# url = 'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/stocks?symbols='
|
||||
url1 = 'https://query1.finance.yahoo.com/v7/finance/quote?fields=regularMarketPrice,regularMarketChangePercent,regularMarketChange®ion=US&lang=en-US&symbols='
|
||||
url1 = 'https://query1.finance.yahoo.com/v7/finance/quote?fields=regularMarketPrice,regularMarketChangePercent,regularMarketChange,regularMarketDayHigh,regularMarketDayLow,regularMarketVolume®ion=US&lang=en-US&symbols='
|
||||
url2 = 'https://cloud.iexapis.com/v1/stock/market/batch?&types=quote&token=pk_aff870df1a984daa9dd43c71801c1936&symbols='
|
||||
url = random.choice([url1, url2])
|
||||
|
||||
@ -177,7 +177,7 @@ def updateStocks(api_key, logf):
|
||||
if len(data) > 0:
|
||||
for symbol in symbols:
|
||||
try:
|
||||
stock_info[data[symbol]['quote']['symbol']] = {'current': data[symbol]['quote']['latestPrice'], 'change': data[symbol]['quote']['change'], 'percent_change':data[symbol]['quote']['changePercent'] * 100}
|
||||
stock_info[data[symbol]['quote']['symbol']] = {'current': data[symbol]['quote']['latestPrice'], 'change': data[symbol]['quote']['change'], 'percent_change':data[symbol]['quote']['changePercent'] * 100, 'day_low':data[symbol]['low'], 'day_high':data[symbol]['high'], 'volume':data[symbol]['latestVolume']}
|
||||
except:
|
||||
pass
|
||||
all_stocks_settings['symbols'] = stock_info
|
||||
@ -216,7 +216,7 @@ def updateStocks(api_key, logf):
|
||||
try:
|
||||
for stock in data['quoteResponse']['result']:
|
||||
if stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B') == symbol:
|
||||
stock_info[stock['symbol'].replace('BRK-A', 'BRK.A').replace('BRK-B', 'BRK.B')] = {'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'], 'day_low': stock['regularMarketDayLow'], 'day_high': stock['regularMarketDayHigh'], 'volume': stock['regularMarketVolume']}
|
||||
except:
|
||||
pass
|
||||
all_stocks_settings['symbols'] = stock_info
|
||||
|
Loading…
Reference in New Issue
Block a user