Skip to content

Instantly share code, notes, and snippets.

Created March 20, 2021 14:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
# ========== Get token ==========
with open("../../tokens/iex_token.txt", "r") as f:
iex_tkn =
# ========== Get symbols to use ==========
symbol_list = ["MSFT", "AAPL", "NVDA", "JNJ", "KHC", "ALL"]
# ========== Get symbols to use ==========
date_range = '3m'
symbol_dict = dict()
for symbol in symbol_list:
outpath = f"data/{symbol}_{date_range}.json"
if not os.path.exists(outpath): # Check that the file isn't already there
resp = get_prices(symbol, iex_tkn, date_param=date_range)
if resp is not None:
prices_obj = parse_resp(resp)
with open(outpath, "w") as f:
json.dump(prices_obj, f)
symbol_dict[symbol] = prices_obj
else:"Data exists for {outpath}, skipping")
with open(outpath, "r") as f:
data_obj = json.load(f)
symbol_dict[symbol] = data_obj
df = utils.symbol_dict_to_df(symbol_dict)
fig = px.line(df, x="date", y="close",
color="symbol", facet_col="symbol", facet_col_wrap=4,
category_orders={"symbol": list(np.sort(df["symbol"].unique()))},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment