Member-only story
IEX Cloud Test 2
import pandas as pd
import requests
from termcolor import colored as cl
import matplotlib.pyplot as plt
plt.style.use(‘seaborn-whitegrid’)
plt.rcParams[‘figure.figsize’] = (15,8)
def get_latest_updates(*symbols):
for i in symbols:
ticker = i
iex_api_key = ‘pk_2711a2706e924888a2a063e6e4cf4307’
api_url = f’https://cloud.iexapis.com/stable/stock/{ticker}/quote?token={iex_api_key}'
df = requests.get(api_url).json()
print(cl(‘Latest Updates of {}\n — — — — — — — ‘.format(ticker), attrs = [‘bold’]))
attributes = [‘symbol’,
‘latestPrice’,
‘marketCap’,
‘peRatio’]
for i in attributes:
print(cl(‘{} :’.format(i), attrs = [‘bold’]), ‘{}’.format(df[i]))
print(cl(‘ — — — — — — — \n’, attrs = [‘bold’]))
get_latest_updates(‘FB’, ‘AAPL’, ‘AMZN’, ‘NFLX’, ‘GOOGL’)
Latest Updates of FB
--------------
symbol : FB
latestPrice : 336.75
marketCap : 961084543104
peRatio : 28.86
--------------
Latest Updates of AAPL
--------------
symbol : AAPL
latestPrice : 129.64
marketCap : 2163384482840
peRatio : 29.2
--------------
Latest Updates of AMZN
--------------
symbol : AMZN
latestPrice…