Back to Community
Fundamentals - python ..... help .....

I'm still new to python and i'm sometimes struggling with it a bit. I need to ask for help with something that is probably trivially simple.
I would like to plot an item of Morningstar fundamental data as a function of time. Pick any one, doesn't matter, but let's say for example:

valuation_ratios.pe_ratio, for AAPL from Jan 2000 to Jan 2017

I can do simple line plots of PRICE easy enough, using:
data = get_pricing('AAPL', start_date='2000-01-01', end_date='2017-01-01')
X = data['price']
plt.plot(X.index, X.values)

but then when it comes to plotting Fundamentals data (instead of price), i'm struggling with figuring out the pandas part & getting the correct syntax for the indexing. Your kind help with just a few lines of code, please, will be much appreciated. Thanks in advance, TonyM.

8 responses


The post mentioned should help. Clone the Notebook included and run it and read it. Look at the factors that are Fundamentals to answer your question.

A slicker way might be included in:
but I'm not sure it's less trouble to understand.


@Alan, many thanks indeed for your kind help. This is exactly the level of understanding that i need. Now i will work through it all carefully to be able to do what i would like to. Cheers, very best wishes, TonyM :-)

Attached notebook to take whatever Fundamentals data that you want from Morningstar, put them into Pipeline, view them as a QC check, and then produce plots vs time. Hopefully this will be useful for someone else besides me.

Thanks to @Alan for getting me started. I found it stretched my (lack of) python skills to the limit, and i kept wondering why plotting Fundamentals data really has to be so hard, when plotting Price data is so easy.

Anyway, I hope that someone else with a better knowledge of python than i have will be able to improve on this, take it further and make it easier.

Notebook attached

Loading notebook preview...
Notebook previews are currently unavailable.

@Tony -- Thanks!
Nice notebook, which is useful for me!

Updated & improved version attached.


Further imporovements welcome ..... anyone?

This is about as far as i can manage to take it. Now would be really nice if some kind pythonic person (not a bumbling newbie amateur like me) could pick this up and take it on a bit further to make it more user-friendly & flexible. See suggestions at end of notebook. Please.

Loading notebook preview...
Notebook previews are currently unavailable.


With attached notebook, you may easily access, list, plot, cross-plot, cross-plot with lag, any Fundamentals data for any time period and symbol(s), using asof_date to check for stale data.


Loading notebook preview...
Notebook previews are currently unavailable.

Many thanks indeed. What you have done is exactly what I was hoping for, and represents a huge step forward from my own clumsy efforts.
I'm sure you will also have the thanks of other people at Q ..... if/when they realize the value & potential of this as a development tool.