Skip to content

Instantly share code, notes, and snippets.

@hesamaseh
Created May 25, 2019 17:06
Show Gist options
  • Save hesamaseh/37a4d651f105c1647993bef6797c2f3c to your computer and use it in GitHub Desktop.
Save hesamaseh/37a4d651f105c1647993bef6797c2f3c to your computer and use it in GitHub Desktop.
Yahoo finance data
import pandas_datareader as pdr
from datetime import datetime
from pandas import DataFrame as df
def get_data(selection, sdate, edate):
data = pdr.get_data_yahoo(symbols=selection, start=sdate, end=edate)
data = df(data['Adj Close'])
return data
start_date = datetime(2017, 1, 1)
end_date = datetime(2019,4,28)
selected = [ 'TD.TO', 'AC.TO', 'BNS.TO', 'ENB.TO', 'MFC.TO','RY.TO','BCE.TO']
print(get_data(selected, start_date, end_date).head(1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment