Created
May 25, 2019 17:06
-
-
Save hesamaseh/37a4d651f105c1647993bef6797c2f3c to your computer and use it in GitHub Desktop.
Yahoo finance data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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