ferc_xbrl_extractor.arelle_interface

Abstract away interface to Arelle XBRL Library.

Module Contents

Classes

References

Pydantic model that defines XBRL references.

Calculation

Pydantic model that defines XBRL calculations.

Metadata

Pydantic model that defines metadata extracted from XBRL taxonomies.

Functions

_taxonomy_view(taxonomy_source[, max_retries])

Actually use Arelle to get a taxonomy and its relationships.

load_taxonomy(path)

Load XBRL taxonomy, and parse relationships.

load_taxonomy_from_archive(taxonomy_archive, entry_point)

Load an XBRL taxonomy from a zipfile archive.

ferc_xbrl_extractor.arelle_interface._taxonomy_view(taxonomy_source: str | arelle.FileSource.FileSource, max_retries: int = 7)[source]

Actually use Arelle to get a taxonomy and its relationships.

ferc_xbrl_extractor.arelle_interface.load_taxonomy(path: pathlib.Path)[source]

Load XBRL taxonomy, and parse relationships.

Parameters:

path – URL or local path pointing to an XBRL taxonomy.

ferc_xbrl_extractor.arelle_interface.load_taxonomy_from_archive(taxonomy_archive: io.BytesIO, entry_point: pathlib.Path)[source]

Load an XBRL taxonomy from a zipfile archive.

Parameters:
  • taxonomy_archive – In memory taxonomy archive.

  • entry_point – Relative path to taxonomy entry point within archive.

class ferc_xbrl_extractor.arelle_interface.References(/, **data: Any)[source]

Bases: pydantic.BaseModel

Pydantic model that defines XBRL references.

FERC uses XBRL references to link Concepts defined in its taxonomy to the physical paper form. These are included in the output metadata and can be useful for linking between XBRL and DBF data.

This model is not a generic representation of XBRL references, but specific to those used by FERC.

account: str[source]
form_location: list[dict[str, str]][source]
class ferc_xbrl_extractor.arelle_interface.Calculation(/, **data: Any)[source]

Bases: pydantic.BaseModel

Pydantic model that defines XBRL calculations.

XBRL calculation relationships are also included in the metadata. Calculations are a validation tool used to define relationships between facts using some mathematical formula. For example, a calculation relationship might denote that one fact is equal to the sum of 2 or more other facts, and this relationship can be used to validate a filing.

name: str[source]
weight: float[source]
class ferc_xbrl_extractor.arelle_interface.Metadata(/, **data: Any)[source]

Bases: pydantic.BaseModel

Pydantic model that defines metadata extracted from XBRL taxonomies.

Taxonomies contain various metedata which are useful for interpreting XBRL filings. The metadata fields being extracted here include references, calculations, and balances.

name: str[source]
references: References[source]
calculations: list[Calculation][source]
balance: Literal[credit, debit] | None[source]
classmethod from_concept(concept: arelle.ModelDtsObject.ModelConcept) Metadata[source]

Get metadata for a single XBRL Concept.

This function will create a Metadata object with metadata extracted for a single Concept.

Parameters:

concept – Concept to extract metadata from.