[Tutor] Does matplotlib.finance still work?

C W tmrsg11 at gmail.com
Fri Aug 25 10:19:45 EDT 2017


I did not mean to leave out the error message, it was very long. I think
the package has been removed.

Anyways, it's here:

>>> quotes = quotes_historical_yahoo_ochl('APX', start, ... )
------------------------------
TypeError: quotes_historical_yahoo_ochl() missing 1 required positional
argument: 'date2'
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-725-467118fe2a8b> in <module>() ----> 1 quotes =
quotes_historical_yahoo_ochl('APX', start, 2 )
TypeError: quotes_historical_yahoo_ochl() missing 1 required positional
argument: 'date2'
------------------------------
------------------------------
>>>
------------------------------
>>> quotes = quotes_historical_yahoo_ochl('APX', start, today)
------------------------------
URLError: <urlopen error [Errno 8] nodename nor servname provided, or not
known>
---------------------------------------------------------------------------
gaierror Traceback (most recent call last)
/Users/anaconda/lib/python3.6/urllib/request.py in do_open(self,
http_class, req, **http_conn_args) 1317 h.request(req.get_method(),
req.selector, req.data, headers, -> 1318
encode_chunked=req.has_header('Transfer-encoding')) 1319 except OSError as
err: # timeout error
/Users/anaconda/lib/python3.6/http/client.py in request(self, method, url,
body, headers, encode_chunked) 1238 """Send a complete request to the
server.""" -> 1239 self._send_request(method, url, body, headers,
encode_chunked) 1240
/Users/anaconda/lib/python3.6/http/client.py in _send_request(self, method,
url, body, headers, encode_chunked) 1284 body = _encode(body, 'body') ->
1285 self.endheaders(body, encode_chunked=encode_chunked) 1286
/Users/anaconda/lib/python3.6/http/client.py in endheaders(self,
message_body, encode_chunked) 1233 raise CannotSendHeader() -> 1234 self.
_send_output(message_body, encode_chunked=encode_chunked) 1235
/Users/anaconda/lib/python3.6/http/client.py in _send_output(self,
message_body, encode_chunked) 1025 del self._buffer[:] -> 1026 self.send(msg
) 1027
/Users/anaconda/lib/python3.6/http/client.py in send(self, data) 963 if self
.auto_open: --> 964 self.connect() 965 else:
/Users/anaconda/lib/python3.6/http/client.py in connect(self) 935 self.sock
= self._create_connection( --> 936 (self.host,self.port), self.timeout,
self.source_address) 937 self.sock.setsockopt(socket.IPPROTO_TCP, socket.
TCP_NODELAY, 1)
/Users/anaconda/lib/python3.6/socket.py in create_connection(address,
timeout, source_address) 703 err = None --> 704 for res in getaddrinfo(host,
port, 0, SOCK_STREAM): 705 af, socktype, proto, canonname, sa = res
/Users/anaconda/lib/python3.6/socket.py in getaddrinfo(host, port, family,
type, proto, flags) 742 addrlist = [] --> 743 for res in _socket.getaddrinfo
(host, port, family, type, proto, flags): 744 af, socktype, proto, canonname
, sa = res
gaierror: [Errno 8] nodename nor servname provided, or not known
During handling of the above exception, another exception occurred:
URLError Traceback (most recent call last)
<ipython-input-727-df8864d6e732> in <module>() ----> 1 quotes =
quotes_historical_yahoo_ochl('APX', start, today)
/Users/anaconda/lib/python3.6/site-packages/matplotlib/finance.py in
quotes_historical_yahoo_ochl(ticker, date1, date2, asobject, adjusted,
cachename) 411 return _quotes_historical_yahoo(ticker, date1, date2,
asobject=asobject, 412 adjusted=adjusted, cachename=cachename, --> 413
ochl=True) 414 415
/Users/anaconda/lib/python3.6/site-packages/matplotlib/finance.py in
_quotes_historical_yahoo(ticker, date1, date2, asobject, adjusted,
cachename, ochl) 501 # warnings.warn("Recommend changing to asobject=None")
502 --> 503 fh = fetch_historical_yahoo(ticker, date1, date2, cachename) 504
505 try:
/Users/anaconda/lib/python3.6/site-packages/matplotlib/finance.py in
fetch_historical_yahoo(ticker, date1, date2, cachename, dividends) 360 else:
361 mkdirs(os.path.abspath(os.path.dirname(cachename))) --> 362 with
contextlib.closing(urlopen(url)) as urlfh: 363 with open(cachename, 'wb') as
fh: 364 fh.write(urlfh.read())
/Users/anaconda/lib/python3.6/urllib/request.py in urlopen(url, data,
timeout, cafile, capath, cadefault, context) 221 else: 222 opener = _opener -->
223 return opener.open(url, data, timeout) 224 225 def install_opener(opener
):
/Users/anaconda/lib/python3.6/urllib/request.py in open(self, fullurl,
data, timeout) 524 req = meth(req) 525 --> 526 response = self._open(req,
data) 527 528 # post-process response
/Users/anaconda/lib/python3.6/urllib/request.py in _open(self, req, data)
542 protocol = req.type 543 result = self._call_chain(self.handle_open,
protocol, protocol + --> 544 '_open', req) 545 if result: 546 return result
/Users/anaconda/lib/python3.6/urllib/request.py in _call_chain(self, chain,
kind, meth_name, *args) 502 for handler in handlers: 503 func = getattr(
handler, meth_name) --> 504 result = func(*args) 505 if result is not None:
506 return result
/Users/anaconda/lib/python3.6/urllib/request.py in http_open(self, req) 1344
1345 def http_open(self, req): -> 1346 return self.do_open(http.client.
HTTPConnection, req) 1347 1348 http_request = AbstractHTTPHandler.
do_request_
/Users/anaconda/lib/python3.6/urllib/request.py in do_open(self,
http_class, req, **http_conn_args) 1318
encode_chunked=req.has_header('Transfer-encoding')) 1319 except OSError as
err: # timeout error -> 1320 raise URLError(err) 1321 r = h.getresponse()
1322 except:
URLError: <urlopen error [Errno 8] nodename nor servname provided, or not
known>

On Fri, Aug 25, 2017 at 6:01 AM, Sydney Shall <s.shall at virginmedia.com>
wrote:

> On 24/08/2017 18:46, Alan Gauld via Tutor wrote:
>
>> On 24/08/17 14:51, C W wrote:
>>
>> I have the following code, I get an error at the first line.
>>>
>>
>> So don't make us guess. What is the error(full text please)?
>>
>> from matplotlib.finance import quotes_historical_yahoo_ochl
>>>
>>
>> And what does a dir() show for matplotlib.finance?
>> Are you sure the name is spelled right etc?
>>
>> I have heard this package is either upgraded or replaced. If so, what do
>>> you recommend?
>>>
>>
>> Contact its author perhaps?
>>
>>
>
> Is this the answer, perhaps.
>
> >>>import matplotlib
>
> >>>dir(matplotlib.finance)
> >>>Traceback (most recent call last):
>
>   File "<ipython-input-2-87d00fcbe86c>", line 1, in <module>
>     dir(matplotlib.finance)
>
>   AttributeError: module 'matplotlib' has no attribute 'finance'
>
> Thanks to Alan G? for his excellent teaching.
>
> --
> Sydney
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list