Skip to main content

 

sec-parser

Essentials ➔       Documentation Status PyPI - License Project Type: Federation Beta
Health ➔              GitHub Workflow Status: ci.yml GitHub Workflow Status: cd.yml Last Commit
Quality ➔             Codacy grade codecov Code Style: Black Ruff
Distribution ➔    PyPI version PyPI - Python Version PyPI downloads
Community ➔     Discord X (formerly Twitter) Follow GitHub stars

Parse SEC EDGAR HTML documents into a tree of elements that correspond to the visual structure of the document.


Overview

The sec-parser project simplifies extracting meaningful information from SEC EDGAR HTML documents by organizing them into semantic elements and a tree structure. Semantic elements might include section titles, paragraphs, and tables, each classified for easier data manipulation. This forms a semantic tree that corresponds to the visual and informational structure of the document. If you're familiar with the Image Semantic Segmentation concept, it's the same but applied to HTML documents.

This tool is especially beneficial for Artificial Intelligence (AI), Machine Learning (ML), and Large Language Models (LLM) applications by streamlining data pre-processing and feature extraction.

Key Use-Cases

sec-parser is versatile and can be applied in various scenarios, including but not limited to:

Financial and Regulatory Analysis

  • Financial Analysis: Extract financial data from 10-Q and 10-K filings for quantitative modeling.
  • Risk Assessment: Evaluate risk factors or Management's Discussion and Analysis sections for qualitative analysis.
  • Regulatory Compliance: Assist in automating compliance checks for the legal teams.
  • Flexible Filtering: Easily filter SEC documents by sections and types, giving you precisely the data you need.

Analytics and Data Science

  • Academic Research: Facilitate large-scale studies involving public financial disclosures, sentiment analysis, or corporate governance exploratory.
  • Analytics Ready: Integrate parsed data seamlessly into popular analytics tools for further analysis and visualization.

AI and Machine Learning

  • Cutting-Edge AI for SEC EDGAR: Apply advanced AI techniques like MemWalker to navigate and extract and transform complex information from SEC documents efficiently. Learn more in our blog post: Cutting-Edge AI for SEC EDGAR: Introducing MemWalker.
  • AI Applications: Leverage parsed data for various AI tasks such as text summarization, sentiment analysis, and named entity recognition.
  • Data Augmentation: Use authentic financial text to train and test machine learning models.

Causal AI

  • Causal Analysis: Use parsed data to understand cause-effect relationships in financial data, beyond mere correlations.
  • Predictive Modeling: Enhance predictive models by incorporating causal relationships, leading to more robust and reliable predictions.
  • Decision Making: Aid decision-making processes by providing insights into the potential impact of different actions, based on causal relationships identified in the data.

Large Language Models

  • LLM Compatible: Use parsed data to facilitate complex NLU tasks with Large Language Models like ChatGPT, including question-answering, language translation, and information retrieval.

These use-cases demonstrate the flexibility and power of sec-parser in handling both traditional data extraction tasks and facilitating more advanced AI-driven analysis.

Disclaimer

Getting Started

This guide will walk you through the process of installing the sec-parser package and using it to extract the "Segment Operating Performance" section as a semantic tree from the latest Apple 10-Q filing.

Open in GitHub Codespaces

Installation

First, install the sec-parser package using pip:

pip install sec-parser

In order to run the example code in this README, you'll also need the sec_downloader package:

pip install sec-downloader

Usage

Once you've installed the necessary packages, you can start by downloading the filing from the SEC EDGAR website. Here's how you can do it:

from sec_downloader import Downloader

# Initialize the downloader with your company name and email
dl = Downloader("MyCompanyName", "email@example.com")

# Download the latest 10-Q filing for Apple
html = dl.get_filing_html(ticker="AAPL", form="10-Q")

Now, we can parse the filing HTML into a list of semantic elements:

# Utility function to make the example code a bit more compact
def print_first_n_lines(text: str, *, n: int):
    print("\n".join(text.split("\n")[:n]), "...", sep="\n")
import sec_parser as sp

elements: list = sp.Edgar10QParser().parse(html)

demo_output: str = sp.render(elements)
print_first_n_lines(demo_output, n=7)
TopSectionTitle: PART I  —  FINANCIAL INFORMATION
TopSectionTitle: Item 1.    Financial Statements
TitleElement: CONDENSED CONSOLIDATED STATEMENTS OF OPERATIONS (Unaudited)
SupplementaryText: (In millions, except number of ...housands and per share amounts)
TableElement: Table with 24 rows, 80 numbers, and 1058 characters.
SupplementaryText: See accompanying Notes to Conde...solidated Financial Statements.
TitleElement: CONDENSED CONSOLIDATED STATEMEN...OMPREHENSIVE INCOME (Unaudited)
...

We can also construct a semantic tree to allow for easy filtering by parent sections:

tree = sp.TreeBuilder().build(elements)

demo_output: str = sp.render(tree)
print_first_n_lines(demo_output, n=7)
TopSectionTitle: PART I  —  FINANCIAL INFORMATION
├── TopSectionTitle: Item 1.    Financial Statements
│   ├── TitleElement: CONDENSED CONSOLIDATED STATEMENTS OF OPERATIONS (Unaudited)
│   │   ├── SupplementaryText: (In millions, except number of ...housands and per share amounts)
│   │   ├── TableElement: Table with 24 rows, 80 numbers, and 1058 characters.
│   │   ├── SupplementaryText: See accompanying Notes to Conde...solidated Financial Statements.
│   ├── TitleElement: CONDENSED CONSOLIDATED STATEMEN...OMPREHENSIVE INCOME (Unaudited)
...

For more examples and advanced usage, you can continue learning how to use sec-parser by referring to the User Guide, Developer Guide, and Documentation.

This was an example of 10-Q SEC Form parsing. How do we parse other SEC Form types, such as 10-K, 8-K, S-1, etc.?

Please refer to this document.

What's Next?

Your turn to explore the capabilities of sec-parser! With the tools and examples provided, you can now dive into parsing and analyzing SEC filings.

The semantic elements and tree structures created by the parser will serve as a solid foundation for your financial analysis and research tasks with the tools of your choice.

For a tailored experience, consider using our free and open-source library for AI-powered financial analysis:

pip install sec-ai

Explore sec-ai on GitHub

Best Practices

How to Import Modules In Your Code

To ensure your code remains functional even when we change the internal structure of sec-parser, it's recommended to avoid deep imports. Here is an example of a deep import (not recommended):

Instead, use the suggested ways to import modules from sec-parser:

Root Import (prefix)

  • import sec_parser as sp. This imports the main package as sp. You can then access its functionalities using sp. prefix.

Root Import (direct)

  • from sec_parser import SomeClass: This allows you to directly use SomeClass without any prefix.

Submodule Import (prefix)

  • import sec_parser.semantic_tree: This imports the semantic_tree submodule, and you can access its classes and functions using semantic_tree. prefix.

Submodule Import (direct)

  • from sec_parser.semantic_tree import SomeClass: This imports a specific class SomeClass from the semantic_tree submodule.

Contributing

For information about setting up the development environment, coding standards, and contribution workflows, please refer to our CONTRIBUTING.md guide.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for sec-parser 0.55.2.post74

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sec-parser 0.55.2.post74
File Size Uploaded Provenance Actions
sec_parser-0.55.2.post74.tar.gz 49.9 kB Without provenance Details for sec_parser-0.55.2.post74.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sec-parser 0.55.2.post74
File Interpreter ABI Platform Actions
sec_parser-0.55.2.post74-py3-none-any.whl Python 3 none any Details for sec_parser-0.55.2.post74-py3-none-any.whl

Total release size: 125.9 kB

Release files / sec_parser-0.55.2.post74.tar.gz

Download URL sec_parser-0.55.2.post74.tar.gz
Size 49.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c83f2f643a9bbbdc44ca3863a6bd0b3d5f2b0712c176b8dfecd490635d948b66
BLAKE2b-256 checksum
How to use checksums
3683cc2ac192b06fae76b1703060339dc200f3ad209c8e170c14123b13458492
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.11.9 Linux/6.5.0-1021-azure

Release files / sec_parser-0.55.2.post74-py3-none-any.whl

Download URL sec_parser-0.55.2.post74-py3-none-any.whl
Size 76.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a6fa3765420c8900a75611ac41ae5b51f5489c5914b561b22cfd23660a75e215
BLAKE2b-256 checksum
How to use checksums
f33dc64601d4c1832786218511b2a557b373795db441180d4332fa63dd91117a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.11.9 Linux/6.5.0-1021-azure

Security for sec-parser 0.55.2.post74

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page