Muestro a continuación, un script que importa cotizaciones históricas de diferentes valores de las bolsas, desde Yahoo, utilizando 'pandas_datareader'.
# 1 - Define `tickers` & `company names` for every instrument
stocks = {'AAPL':'Apple', 'MSFT':'Microsoft', 'AMZN' : 'Amazon', 'GOOG': 'Google', 'FB':'Facebook','NFLX':'Netflix' , 'NVDA' : 'NVIDIA'}
bonds = {'HCA' : 'HCA', 'VRTX' : 'VRTX'}
commodities = {'BTC-USD' : 'Bitcoin', 'PA=F' : 'Palladium'}
instruments = {**stocks, **bonds, **commodities}
tickers = list(instruments.keys())
instruments_data = {}
N = len(tickers)
# 2 - We will look at stock prices over the past years, starting at January 1, 2015
# 01-01-2015 - 16-04-2020
start = datetime.datetime(2015,1,1)
end = datetime.datetime(2020,4,16)
# 3 - Let's get instruments data based on the tickers.
# First argument is the series we want, second is the source ("yahoo" for Yahoo! Finance), third is the start date, fourth is the end date
for ticker, instrument in instruments.items():
print("Loading data series for instrument {} with ticker = {}".format(instruments[ticker], ticker))
instruments_data[ticker] = web.DataReader(ticker, data_source = 'yahoo', start = start, end = end)
La sentencia instruments = {**stocks, **bonds, **commodities}
, intuyo que crea un diccionario con tres diccionarios. No entiendo qué función tienen los dos '**'. Agradeceré me expliquéis esta sentencia.