IEX API working
This commit is contained in:
parent
dbc750ed67
commit
5db785d662
@ -100,7 +100,7 @@ def updateUpdate(NY_time):
|
||||
f.write(NY_str + '\n')
|
||||
f.close()
|
||||
|
||||
def updateStockPrices():
|
||||
def updateStockPricesFinhubb():
|
||||
max_stocks = 200
|
||||
finnhubsandboxAPIkey = "sandbox_c24qddqad3ickpckgg8g" #Finnhub
|
||||
finnhubAPIkey = "c24qddqad3ickpckgg80" #Finnhub
|
||||
@ -136,7 +136,7 @@ def updateStockPrices():
|
||||
print(e)
|
||||
|
||||
|
||||
def updateStockPricesIEX():
|
||||
def updateStockPrices():
|
||||
|
||||
iexAPIkey = 'pk_68ef6a15902c41f887f0b544a0ca17cf' #IEX
|
||||
iexSandboxAPIkey = 'Tpk_0078dff413ef4f979137f7111452dc4b'
|
||||
@ -188,14 +188,22 @@ def updateStockPricesIEX():
|
||||
print('Response code: \n',intraday_response)
|
||||
|
||||
|
||||
print(intraday_response.text)
|
||||
|
||||
opn = intraday_response.json()[0]['open']
|
||||
current = intraday_response.json()[-1]['close']
|
||||
#print(intraday_response.text)
|
||||
|
||||
for i in range(len(intraday_response.json())):
|
||||
opn = intraday_response.json()[i]['open']
|
||||
print(opn)
|
||||
if opn is not None:
|
||||
break
|
||||
for i in range(len(intraday_response.json())-1, 0, -1):
|
||||
|
||||
current = intraday_response.json()[i]['close']
|
||||
if current is not None:
|
||||
break
|
||||
|
||||
opening_prices.append(opn)
|
||||
current_prices.append(current)
|
||||
|
||||
print(opn, current)
|
||||
'''
|
||||
for time_point in intraday_response.json():
|
||||
print(time_point['date'])
|
||||
@ -608,6 +616,8 @@ if __name__ == '__main__':
|
||||
#update_times = {'stocks':NY_str, 'crypto':NY_str, 'news':NY_str, 'weather': NY_str, 'forex': CET_str} # all in NY time apart from forex in CET
|
||||
#json.dump(update_times, f)
|
||||
#f.close()
|
||||
|
||||
|
||||
|
||||
try:
|
||||
f = open('csv/last_updates.json', 'r')
|
||||
|
@ -1,4 +1,4 @@
|
||||
name,current,opening
|
||||
MSFT,276.845,278.03
|
||||
NFLX,541.92,533
|
||||
GOOG,2589.7622,2588.99
|
||||
MSFT,277.355,278.02
|
||||
NFLX,542.15,532.56
|
||||
GOOG,2595.72,2588.01
|
||||
|
|
Loading…
Reference in New Issue
Block a user