edgartools icon indicating copy to clipboard operation
edgartools copied to clipboard

XBRL2 Period Views

Open kalavrcom opened this issue 1 year ago • 7 comments

Hi Dwight,

Thank you for this incredible library!

We saw that you dropped the updated XBRL2 parser and statement stitching and ran the example notebook that you provided. This is a huge step forward.

While your notebook example worked well for AAPL and GOOGL, we tried the same code with INTC and noted some issues with the following period views:

  1. xbrl.render_statement("IncomeStatement", period_view="YTD and Quarterly Breakdown") returns empty/NaN/null values
  2. xbrl.render_statement("IncomeStatement", period_view="Three Recent Quarters") returns empty/NaN/null values
  3. xbrl.render_statement("CashFlowStatement", period_view="YTD and Quarterly Breakdown") returns an almost entirely empty statement
  4. xbrl.render_statement("CashFlowStatement", period_view="Three Recent Quarters") returns empty/NaN/null values
  5. xbrl.render_statement("CashFlowStatement", period_view="Current vs. Previous Periods") renders even though that specific option isn't listed in the INTC cash flow statement period list. The output seemed to correspond to the "Three-Year Comparison" response instead.
  6. Further to point no. 5 above, when we used an invalid period_view for BalanceSheet it doesn't seem like there's error validation to ensure that the period_view parameter called by render_statement corresponds to one of the available period views from get_period_views.

kalavrcom avatar Mar 14 '25 01:03 kalavrcom

Thanks for testing. I need to spend some time with Period View. This was one of the few features the AI designed and to be honest it came up with this design on its own. So it's not something where I know how it works. That being said - is it potentially a useful feature? If so I will work to understand and fix these issues

dgunning avatar Mar 14 '25 18:03 dgunning

That being said - is it potentially a useful feature?

This is an absolute must in order to work with the MultiFinancials method properly, or for me to construct an equivalent from scratch, because MultiFinancials doesn't seem to work well with a mixture of form types (e.g. 10-K and 10-Q). My main use-case is that I'm trying to construct a similar dashboard as any standard stock financial website (e.g. YahooFinance, Google Stocks, Bing) where you might list the last 3-5 fiscal years of the three financial statement types (Income Statement, Balance Sheet, Cash Flow Statement) plus LTM/TTM equivalents.

When I tried to something like this with MultiFinancials I ran into three issues:

  1. The columns were unordered because the date columns are strings; I converted these into timedate once I was able to extract the tables into a pandas dataframe.
  2. 10-Ks as extracted by MultiFinancials seems to understandably pull an aggregated final number which requires me to then try to calculate the last 3 preceeding quarters to subtract from the annualized view to calculate the Q4 numbers for the three statements.
  3. I got stuck here because sometimes (e.g. INTC) the MultiFinancials method would extract the tables using the 6-month view instead of the 3-month view and I couldn't find a toggle/parameter that would let me choose a specific period when multiple periods are available and parsed from the 10-Q or 10-K.

Therefore, when I saw the period_view feature I was really excited because I was hoping this meant I could constrct the LTM view myself.

If there's a way to do what I'm asking above and I just missed it in the documentation please let me know! But separately, it is interesting that INTC seems to cause problems where AAPL and GOOGL do not (from a testing perspective).

kalavrcom avatar Mar 14 '25 19:03 kalavrcom

Thanks for this detailed writeup and also for the motivations behind period views. I just finished the 3rd daily release of the rewrite and will now turn attention ton period views. Will let you know how it goes

dgunning avatar Mar 15 '25 16:03 dgunning

Started looking into period views. It's likely no data is available for INTC for those period views but it was harder than I'd like to tell. So I plan to implement a Facts component that's query functionality so I can see all facts for a period or any other attribute. But first I did some refactoring on the AI generated code to make it more maintainable. Will try to make progress on period view later today.

dgunning avatar Mar 17 '25 12:03 dgunning

I'm finishing up the new Facts query component and will push the changes and a notebook later. I think it's a data issue where INTC just doesn't have the data to populate the custom period views for those statements. Now I'm 90-95% sure about this but to be sure I might do some manual digging through the XBRL, or ask Claude for some validation code

dgunning avatar Mar 17 '25 20:03 dgunning

Will do some testing of PeriodViews as part of the 4.0 release that I'm working on now

dgunning avatar Apr 10 '25 18:04 dgunning

Just as a follow-up to this, I was able to reconstruct the LTM (last twelve month) view by downloading the last 6 available 10-Q statements, isolating and calculating Q4 numbers from the last 2 10-K statements, and then stitching those together, as a workaround to period_views.

kalavrcom avatar Jun 17 '25 13:06 kalavrcom