In a Research notebook I'm using the following code to fetch prices for numerous stocks:

tickers = ['LAMR','OUT','AIV','AVB','CPT','EQR','ESS','MAA','UDR','COR','CONE','DLR', 'EQIX','IRM','QTS','ALX','EPR','JBGS','VNO','WPC','PEAK', 'WELL','VTR','MPW','SNR','PLD','PSB','STAY','GLPI','HST', 'HT','IHT','MGP','PK','VICI','XHR','SUI','UMH','NLY','ANH', 'AI','ARE','BXP','BDN','OFC','CUZ','HPP','CLI','SLG','CXW', 'GEO','CBL','MAC''PEI','SPG','TCO','WPG','CUBE','EXR','LSI', 'PSA','BRX','CDR','FRT','KIM','RPT','REG','SITC','SKT','UBP','WRI', 'NNN','O','AMH','INVH','ACC','AMT','CCI','SBAC','PCH','RYN','WY'] symbols = [qb.AddEquity(ticker, Resolution.Daily).Symbol for ticker in tickers] ef get_prices(symbols,months): """ generate a DataFrame with monthly stock prices. The first and last entries are full months """ now = datetime.now() history = qb.History(symbols, (now-timedelta(days=months*30)).replace(day=1), now.replace(day=1)-timedelta(days=1), Resolution.Daily).drop(['high','low','open','volume'],1) history = history.unstack(level=0).resample('M').last().to_period('M').dropna(axis=1) history.columns = history.columns.map(''.join).str.lstrip('close_') history.columns = history.columns.str.split(' ').str[0] del history.columns.name del history.index.name return history prices = get_prices(symbols,50) prices['WPG'].head()

On the last line, I get a

KeyError: 'WPG VQY4YY1HBASL'How come? It doesn't happen with any Dataframe not created by History. Am I missing something very basic?Thanks.

Author