Skip to content

Instantly share code, notes, and snippets.

@yuyasugano
Last active September 22, 2020 07:24
Show Gist options
  • Save yuyasugano/bc7405789d5dbae19b81f705be34adc8 to your computer and use it in GitHub Desktop.
Save yuyasugano/bc7405789d5dbae19b81f705be34adc8 to your computer and use it in GitHub Desktop.
Pandas Datareader for single stock data
#!/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