Skip to content

Instantly share code, notes, and snippets.

Created September 15, 2020 10:33
What would you like to do?
Pandas Datareader for multiindex stock data
import datetime
import numpy as np
import pandas as pd
import as pdr
# fetch multiple asset data
def getMultiAssetData(ticketList, date_from, date_to):
def getData(ticker):
data = pdr.DataReader(ticker, 'yahoo', date_from, date_to)
return data
datas = map(getData, tickerList)
return pd.concat(datas, keys=tickerList, names=['Ticker', 'Date'])
date_from =, 1, 1)
date_to =, 8, 31)
tickerList = ['AAPL', 'AMZN', 'CCEP', 'FB', 'JNJ', 'JWN', 'NVS', 'PG']
multiData = getMultiAssetData(tickerList, date_from, date_to)
df = multiData.copy()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment