Last active
September 22, 2020 07:24
-
-
Save yuyasugano/bc7405789d5dbae19b81f705be34adc8 to your computer and use it in GitHub Desktop.
Pandas Datareader for single stock 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
#!/usr/bin/python | |
import warnings | |
import numpy as np | |
import pandas as pd | |
import pandas_datareader.data as pdr | |
warnings.simplefilter('ignore', FutureWarning) | |
# fetch single asset data | |
def getSingleAssetData(ticker, date_from, date_to): | |
def getData(ticker): | |
data = pdr.DataReader(ticker, 'yahoo', date_from, date_to) | |
return data | |
return getData(ticker) | |
date_from = datetime.date(2019, 1, 1) | |
date_to = datetime.date(2020, 8, 31) | |
df = getSingleAssetData('AMZN', date_from, date_to) # read Amazon.com, Inc | |
df.head() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment