Financial Statement from Morningstar Data - Need help from accounting-savvy users.

Hi there,

I'm working on this notebook to get Morningstar's financial data and then to display them similar to how Morningstar did it. This is going to be superior to the one on Morningstar's site in the following matters:

1. Support for Trailing Four Quarters. Financial reports in the Morningstar site only support either quarterly or annual, we can't get, say, trailing four quarters every second quarter for the last 10 years.
2. Longer data period. Even Morningstar's premium account has only 10 years of data, and they are only annual data. This notebook supports longer periods on a quarterly basis.

However! As I was matching the items in the documentation with the ones from Morningstar, my lack of accounting knowledge had made this project too challenging for me. Some items simply do not match. For example, the item "General and Administrative Expenses" from Morningstar does not match with the one from Quantopian Research.

How to Help

If you're interested to help, I have made the notebook quite easy to configure. Basically, all you need to do is to adjust this dictionary:

MODES = {
'bs-basics': [
# asof_date is a must-have
('asof_date', Fundamentals.total_assets_asof_date, None),
...
],
'is-basics': [
# asof_date is a must-have
('asof_date', Fundamentals.total_assets_asof_date, None),
('Business Revenue', Fundamentals.operating_revenue, TRAILING_SUM),
...
]
}


To add a new item, for example, you may add a line like so:

('Total Revenue', Fundamentals.total_revenue, TRAILING_SUM),


That line means: Add a line item "Total Revenue" from the data field Fundamentals.total_revenue and for annual report, sum the amount of all four quarters. The last instruction comes from the setting TRAILING_SUM. In contrast, for a balance sheet item that lists a point-in-time data, you'd want to set it to TRAILING_LATEST, like so:

('total_assets', Fundamentals.total_assets, TRAILING_LATEST),


The list of fields is available from Quantopian's documentation on Morningstar Fundamentals.

Other Features

In the first code cell, there are a few configurations you can change. Most are quite straightforward, but there are a couple of unique ones:

1. PERIOD: Set this to 'annual', or 'quarterly', or a number. When set with a number, it skips this number of quarters. e.g. annual is the same as setting this parameter to 4.
2. NUM_PERIODS: How far back to go. Setting to 4 on 'annual' period means there are four years, for instance.
3. DATE: The format is YYYY-MM-DD
4. MODE: In the third code block, there is a dictionary named MODES which content I have included above. See that there are two options, 'bs-basics' (bs stands for balance sheet) and 'is-basics' (income statement). You may choose the mode to display here.
5. FORMAT_ROUNDING: Divide the values in the report by this number for better presentation. Exceptions can be set in the last code cell.
6. In the last code cell, under the "5. Presentation" section, you may adjust how the data are presented. In this case, we do not want to divide "Basic EPS" and "Diluted EPS" by 1 million so we put the exceptions in this line:
if idx in ['Basic EPS', 'Diluted EPS']:


Future Work

This notebook is a work in progress. I'll continue working on this once I've seen some progress with the data. Some additional features I already have in mind:

1. Basic and Diluted EPS should be trailing average instead of latest. There should be a TRAILING_AVG option.
2. When including Basic and Diluted EPS, 10-year annual data freezes the notebook when running.
3. fields combination and calculation. For now, if there are fields in the documentation that needs to be combined or updated to get the correct financial statement values, let me know.