I currently have the following code whereby I used exec() to help create variable names in the for loop. Any idea how I can call up the variables outside of the for loop? I tried stock_{i} but didnt work.
stocks = ['GS', 'FB']
date0 = '2019-12-31'
date1 = '2019-01-01'
def get_stock_prices(stk, start, end):
ts = TimeSeries(key = api_key, output_format = 'pandas')
data, meta_data = ts.get_daily(stk, outputsize = 'full')
adj_data = data.loc[start:end]
print(adj_data)
for i in stocks:
exec(f'stock_{i} = get_stock_prices(i, date0, date1)')