I am doing a Finance project in Python. I am using pandas dataframes and DataReader to get stock data for different banks. I have a list of 'tickers' which are an input for the following function:
tickers= ['BAC','C','GS','JPM','MS','WFC'] # list of tickers
BAC = data.DataReader('BAC', 'stooq', start, end). # example function for 1st element
I could write the function for each element of the list and store it in a different variable. But I would like to automate this process and instead create a function which iterates through the tickers and calls a variable to fill it in with whichever element in the list. Help me out?
I believe what you want is a simple for loop as a starting point:
The returned_values list will contain all your returned values.