[Tutor] Does matplotlib.finance still work?

C W tmrsg11 at gmail.com
Sat Aug 26 13:16:55 EDT 2017


Thanks Alan. You are right, the finance.py is there.

I think quotes_historical_yahoo is from 3 years ago. It is replaced by
quotes_historical_yahoo_ochl and quotes_historical_yahoo_ohlc.

But the problem is, yahoo finance has also changed its API (2 years ago?).
It is a complete overhaul.

quotes_historical_yahoo_ochl has not kept up. Thus, the error message.

help(quotes_historical_yahoo_ochl)
------------------------------
Help on function quotes_historical_yahoo_ochl in module matplotlib.finance:
quotes_historical_yahoo_ochl(ticker, date1, date2, asobject=False,
adjusted=True, cachename=None) Get historical data for ticker between date1
and date2. See :func:`parse_yahoo_historical` for explanation of output
formats and the *asobject* and *adjusted* kwargs. Parameters ----------
ticker : str stock ticker date1 : sequence of form (year, month, day),
`datetime`, or `date` start date date2 : sequence of form (year, month,
day), `datetime`, or `date` end date cachename : str or `None` is the name
of the local file cache. If None, will default to the md5 hash or the url
(which incorporates the ticker and date range) Examples -------- >>> sp =
f.quotes_historical_yahoo_ochl('^GSPC', d1, d2, asobject=True,
adjusted=True) >>> returns = (sp.open[1:] - sp.open[:-1])/sp.open[1:] >>>
[n,bins,patches] = hist(returns, 100) >>> mu = mean(returns) >>> sigma =
std(returns) >>> x = normpdf(bins, mu, sigma) >>> plot(bins, x,
color='red', lw=2)

Thank you very much!

On Fri, Aug 25, 2017 at 1:01 PM, Alan Gauld via Tutor <tutor at python.org>
wrote:

> On 25/08/17 15:19, C W wrote:
> > I did not mean to leave out the error message, it was very long.
>
> That just means it has a lot of information in it :-)
>
> >  I think the package has been removed.
>
> I don;t think so based on the traceback...
>
> >>>> quotes = quotes_historical_yahoo_ochl('APX', start, ... )
> > ------------------------------
> > TypeError: quotes_historical_yahoo_ochl() missing 1 required positional
> > argument: 'date2'
>
> Did you check what parameters were required for this function?
> The error says you are missing one.
>
> > /Users/anaconda/lib/python3.6/site-packages/matplotlib/finance.py in
>
> Note the filename. That suggests finance.py is still there.
>
> > 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:
>
> Some warnings there that might be relevant, I don't know
> anything about the package or function.
>
> You could try running the help() function:
>
> >>> help(quotes_historical_yahoo_ochl)
>
> And see if it shows anything useful.
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> _______________________________________________
> 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