-
-
Notifications
You must be signed in to change notification settings - Fork 479
ParsingXBRL
Some SEC filings include data in XBRL (eXtensible Business Reporting Language) format. Edgartools provides ways to extract and use this data.
XBRL can either be embedded in the filing or provided as attachments to the filing. This guide focuses on extracting XBRL from filing attachments.
Inline XBRL is also being parsed using HTMLDocument.from_html(html) and the data is available but for now this parser is not completely developed.
To list all filings that include XBRL use index="xbrl" in the get_filings function.

filings = get_filings(index="xbrl")Some forms like 424B2 offerings have only the XBRL instance document as an attachment. For these filings the XBRL parser will extract only an XBRLInstance class containing the data from the instance document.
XBRLDocuments(filings[0].attachments)
Other forms like 10-K have multiple XBRL attachments.
These will be parsed into an XBRLData class containing the XBRLInstance but also include information about the labels, the presentation, the calculations and other details that allow for precise analysis of the XBRL data.
XBRLDocuments(filings[2].attachments)
The XBRL parser is integrated within edgartools so it is as simple as calling filing.xbrl()
- If there is no attached XBRL this will return
None. - If there is only the XBRL instance document this will return an
XBRLInstanceobject. - If there are multiple XBRL attachments this will return an
XBRLDataobject.
The XBRLInstance object contains the data extracted from the XBRL instance document in a dataframe facts. For example, see the XBRL Instance for a 424B4.
This has 8 facts in the dataframe.

You can query the underlying facts using pandas syntax
instance.facts.query("concept=='ffd:FormTp'")Alternatively you can use the convenience function
instance.query_facts(concept='ffd:FormTp')This is useful if the facts have dimensions, which simple XBRL do not. We will look at dimensioned facts later.
XBRLData is the container for all the XBRL data extracted from the filing. It contains the XBRLInstance as well as the labels, presentation, calculations and other data that is extracted from the filing.
Importantly, it contains all the Statement's extracted from the filing. These are shown when displaying the XBRLData object.
filing = filings[2]
xbrl_data = filing.xbrl()