r/Python • u/Early-Sir-932 • 28d ago
Discussion Pulling numbers from 10-K and 10-Q filings: XBRL or parse the document?
for income statement, balance sheet and cash flow numbers from 10-k and 10-q filings there are two routes and theyre good at different things.
xbrl uses the tagged data that comes with the filing. the secs companyfacts api returns every tagged fact for a company as json, theres bulk financial statement data sets too and edgartools or secxbrl wrap a lot of it. machine readable so no parsing errors.
it does get messy though. companies use their own extension tags so the same line item can have different names across companies. segment and dimensional facts sit right next to the consolidated totals and are easy to mix up and restated numbers show up in later filings so you have to pick the right period and filing.
parsing the actual document still helps for md&a, footnotes and risk factors, which mostly arent tagged as numbers. same for older filings from before xbrl was required and for checking what the table on the page actually shows when the tags look off
edgar has most of these as html but plenty of people end up working from the pdf versions off investor relations pages, and those need an actual parser to keep the tables in one piece like docling, marker or llamaparse, that kind of thing. but not really necessary for simple tasks
so xbrl for the core statements and parsing for the text and edge cases seems like the sane default