I am trying to make the below short code to work. My focus is in fetch_historical_yahoo
which seems not to be working. I am trying to use it in a larger code.
import datetime
import matplotlib.finance as finance
import matplotlib.mlab as mlab
startdate = datetime.date(2005,1,1)
today = enddate = datetime.date.today()
ticker = 'nvda'
fh = finance.fetch_historical_yahoo(ticker, startdate, enddate)
r = mlab.csv2rec(fh); fh.close()
r.sort()
When I run the code, I get the below error. When I go and open finance.py I can't seem to be able to place my finger on the url
issue.
Any ideas?
I tried mlp_finance
but I was nopt able to install it.
fh = finance.fetch_historical_yahoo(ticker, startdate, enddate)
Traceback (most recent call last):
File "<ipython-input-61-e83eb3d28a19>", line 1, in <module>
fh = finance.fetch_historical_yahoo(ticker, startdate, enddate)
File "C:\Users\dvargas\Anaconda3\lib\site-packages\matplotlib\finance.py", line 362, in fetch_historical_yahoo
with contextlib.closing(urlopen(url)) as urlfh:
File "C:\Users\dvargas\Anaconda3\lib\urllib\request.py", line 163, in urlopen
return opener.open(url, data, timeout)
File "C:\Users\dvargas\Anaconda3\lib\urllib\request.py", line 466, in open
response = self._open(req, data)
File "C:\Users\dvargas\Anaconda3\lib\urllib\request.py", line 484, in _open
'_open', req)
File "C:\Users\dvargas\Anaconda3\lib\urllib\request.py", line 444, in _call_chain
result = func(*args)
File "C:\Users\dvargas\Anaconda3\lib\urllib\request.py", line 1282, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "C:\Users\dvargas\Anaconda3\lib\urllib\request.py", line 1256, in do_open
raise URLError(err)
URLError: <urlopen error [Errno 11004] getaddrinfo failed>