Skip to main content

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

Project description

 

sec-parser

Essentials ➔       Documentation Status Licence Project Type: Federation Beta
Health ➔              GitHub Workflow Status: ci.yml GitHub Workflow Status: cd.yml Last Commit
Quality ➔             codecov Code Style: Black Ruff
Distribution ➔    PyPI version PyPI - Python Version PyPI downloads
Community ➔     HitCount 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.

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 evaluation.
  • 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.

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.

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_latest_html("10-Q", "AAPL")

Note The company name and email address are used to form a user-agent string that adheres to the SEC EDGAR's fair access policy for programmatic downloading. Source

Now, we can parse the filing into semantic elements and arrange them into a tree structure:

import sec_parser as sp

# Parse the HTML into a list of semantic elements
elements = sp.Edgar10QParser().parse(html)

# Construct a semantic tree to allow for easy filtering by section
tree = sp.TreeBuilder().build(elements)

# Find section "Segment Operating Performance"
section = [n for n in tree.nodes if n.text.startswith("Segment")][0]

# Preview the tree
print("\n".join(sp.render(section).split("\n")[:13]) + "...")
TitleElement: Segment Operating Performance
├── TextElement: The following table sho... (dollars in millions):
├── TableElement: 414 characters.
├── TitleElement[L1]: Americas
│   └── TextElement: Americas net sales decr... net sales of Services.
├── TitleElement[L1]: Europe
│   └── TextElement: The weakness in foreign...er net sales of iPhone.
├── TitleElement[L1]: Greater China
│   └── TextElement: The weakness in the ren...er net sales of iPhone.
├── TitleElement[L1]: Japan
│   └── TextElement: The weakness in the yen..., Home and Accessories.
└── TitleElement[L1]: Rest of Asia Pacific
    ├── TextElement: The weakness in foreign...lower net sales of Mac....

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.

What's Next?

You've successfully parsed an SEC document into semantic elements and arranged them into a tree structure. To further analyze this data with analytics or AI, you can use any tool 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

Importing modules

  1. Standard: import sec_parser as sp
  2. Package-Level: from sec_parser import SomeClass
  3. Submodule: from sec_parser import semantic_tree
  4. Submodule-Level: from sec_parser.semantic_tree import SomeClass

Note The root-level package sec_parser contains only the most common symbols. For more specialized functionalities, you should use submodule or submodule-level imports.

Warning To allow us to maintain backward compatibility with your code during internal structure refactoring for sec-parser, avoid deep or chained imports such as sec_parser.semantic_tree.internal_utils import SomeInternalClass.

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.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sec_parser-0.18.0.post16.tar.gz (28.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sec_parser-0.18.0.post16-py3-none-any.whl (37.1 kB view details)

Uploaded Python 3

File details

Details for the file sec_parser-0.18.0.post16.tar.gz.

File metadata

  • Download URL: sec_parser-0.18.0.post16.tar.gz
  • Upload date:
  • Size: 28.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.5 Linux/6.2.0-1012-azure

File hashes

Hashes for sec_parser-0.18.0.post16.tar.gz
Algorithm Hash digest
SHA256 c5bf643d69a57ac007540d3f97242b5111938151a1d9ee7afd2f7ce67077301d
MD5 1086d487d1fd2925998b692f298d4945
BLAKE2b-256 ceec4ec22999ca4cc8aae6e2c82ab4b7fcbf6d0a6aa6f94c7a55ac8a1a581b36

See more details on using hashes here.

File details

Details for the file sec_parser-0.18.0.post16-py3-none-any.whl.

File metadata

  • Download URL: sec_parser-0.18.0.post16-py3-none-any.whl
  • Upload date:
  • Size: 37.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.5 Linux/6.2.0-1012-azure

File hashes

Hashes for sec_parser-0.18.0.post16-py3-none-any.whl
Algorithm Hash digest
SHA256 072cfdf8d5b816ab53637b5c2622663d55c27aa3169ddfd53b977dba74e60fc6
MD5 5852e64901e4ac98c96c511440831ff5
BLAKE2b-256 1ce56e4b4dff7de21319dec1f1b825988c6faa23b6b37e6c277d68bb1560aa8e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page