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)
plt.ylabel('Price')
plt.legend(['AAPL']);

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

Tony,

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.
https://www.quantopian.com/posts/analyzing-pipeline-data-from-research-notebook-how-to-get-data-using-equity-object

A slicker way might be included in:
https://www.quantopian.com/posts/new-pipeline-features-slicing-and-correlation-slash-regression-methods
but I'm not sure it's less trouble to understand.

alan

@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
TonyM.

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

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

Updated & improved version attached.

DISPLAY OF MORNINGSTAR FUNDAMENTALS DATA

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.

@Tony

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.

Enjoy,
Doug

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

@Doug,
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.