AAPL Consolidated Balance Sheet - Cannot parse repeated line-item in both current & non-current assets
AAPL, like many other companies, displays their balance sheet asset section in two categories: Current and Non-current Assets.
I noticed in this specific case "Marketable Securities" shows up in both categories, but the XBRL is only parsing one of them (seems like the instance furthest down the page), and doesn't differentiate between the two in the report nor the dataframe.
This is an issue because it means a custom financial dashboard relying on Edgartools is unable to calculate a "Cash & Cash Equivalents + Short-Term Investments", which is what almost all existing financial dashboards (e.g. Google Finance, Koyfin, Interactive Brokers, Bing, etc.) show in a condensed format.
Code to generate this behaviour and corresponding outputs are shown below:
c = Company("AAPL")
f = c.get_filings(form="10-K", year=[2025, 2024, 2023, 2022])
ff = XBRLS.from_filings(f)
bb = ff.statements.balance_sheet()
bb.to_dataframe()
You can see from the output above in dataframe row 17 that "Marketable Securities" only shows up one time as a current asset, but the numbers correspond to AAPL's 10-K balance sheet section showing the non-current marketable securities (wrong location), while not showing the current marketable securities (i.e. STI) figure at all.
I wasn't fully aware of the facts views before so I used the following code to see if there was an issue earlier in the XBRL pipeline, but the parser seems fine since the facts for MarketableSecurities (current & non-current) show the correct figures that match the 10-K excerpt above for AAPL's FY2024 10-K. I generally use Polars for my dataframes so that will be an additional dependency you will need to bring in to run the code below although one should be able to replicate by filtering/searching a Pandas dataframe also.
fx = pl.DataFrame(c.get_facts().to_pandas()) # create polars df from panadas df
fx.filter(pl.col('fact').str.contains('MarketableSecurities') & (pl.col('form') == '10-K') & (pl.col('fy') == 2024)) # filter rows based on three conditions
Output:
Found the issue in the standardization logic. I have added new mappings for Current Marketable Securities and Non Current Marketable Securities so that they would be distinct in the Balance Sheet view. Will include in a release over the next few days
Fixed in Release 4.2.1
Thanks Dwight! This is working!