Skip to main content

Edgar Financial Analysis Toolkit

A Python package for extracting and analyzing financial statement data from SEC filings using XBRL data and Yahoo Finance.

Key Features

  • Extract financial data from SEC filings using edgartools
  • Support for balance sheet, income statement, and cash flow statement items
  • Calculate annual, quarterly, and trailing twelve month (TTM) metrics
  • Flexible matching of accounting concepts with regex patterns
  • Integration with Yahoo Finance in order to find correct accounting items
  • Clean, standardized output in pandas DataFrames

Installation

pip install edgartools==3.15.1
pip install yfinance pandas

Dependencies

  • Python 3.7+
  • edgartools (3.15.1)
  • yfinance
  • pandas
  • numpy
  • pydantic

Core Components

Accounting Item Configuration

  • AccountingItem class defines how to match and process financial statement items
  • Pre-configured items for common metrics (Revenue, Total Assets)
  • Flexible matching strategies (concept, label, union, intersection)

Data Extraction

  • Uses edgartools to download and parse XBRL filings
  • Caches filings for efficient repeated analysis
  • Handles both instant (balance sheet) and duration (income statement) items

Analysis Features

  • Calculate trailing twelve month (TTM) metrics from quarterly data
  • Standardize reporting frequencies (annual, quarterly, TTM)
  • Combine SEC data with Yahoo Finance data when available

Configuration

EDGAR Identity

You must set your identity before making requests to EDGAR

from edgar import set_identity
set_identity('your.name@example.com')

Usage Example

# Download trailing twelve months Revenue data for the past six quarters 
# and last four annual Total Asset figures for Wallmart, Inc.

from edgar import set_identity
from edgar_analysis.company_analysis import CompanyAnalysis

# Set your identity for SEC EDGAR access
set_identity('your.email@example.com')

# Analyze a company
analyst = CompanyAnalysis(ticker='WMT')

# Get revenue data
revenues = analyst.get_revenues(periods=6, frequency='ttm')
print(revenues)

# Get total assets
assets = analyst.get_total_assets(periods=4, frequency='annual')
print(assets)

Plotting Example

# Plot last eight quarterly Revenues for Apple, Inc.
import matplotlib.pyplot as plt
from edgar_analysis.company_analysis import CompanyAnalysis

analyst = CompanyAnalysis(ticker='AAPL')
revenues = analyst.get_revenues(periods=8, frequency='quarterly')

revenues.T.plot()  # Transpose for dates on x-axis
plt.title('Apple Quarterly Revenue')
plt.ylabel('Revenue ($)')
plt.show()

Available Accounting Items

Currently configured items are:

  • Revenue (Income Statement)
  • Total Assets (Balance Sheet)

The system is designed to be easily extended with additional accounting items.

SEC EDGAR & Yahoo Finance Data Matching

The SEC EDGAR API provides financial data for companies, but accounting item names (labels and contexts) can vary across companies and even change over time for the same company.

To standardize this data, I use regular expressions (regex) to identify accounting items that likely match a desired concept (e.g., "Revenues").

How It Works:

  1. Yahoo Finance Data: The script retrieves the latest 4 years and 4 quarters of financial data for free.

  2. Matching Process: When reporting dates overlap between SEC EDGAR and Yahoo Finance, the script aligns the data to map the correct accounting line items.

  3. Historical Consistency: Since companies often report current and prior-period results, this mapping ensures the correct labels and concepts are linked to their values.

This approach improves accuracy when extracting financial metrics from SEC filings.

Metadata

Release files for edgar-analysis 0.1.1

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

Source distribution (sdist)

Source distribution for edgar-analysis 0.1.1
File Size Uploaded Provenance Actions
edgar_analysis-0.1.1.tar.gz 25.9 kB Without provenance Details for edgar_analysis-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for edgar-analysis 0.1.1
File Interpreter ABI Platform Actions
edgar_analysis-0.1.1-py3-none-any.whl Python 3 none any Details for edgar_analysis-0.1.1-py3-none-any.whl

Total release size: 54.6 kB

Release files / edgar_analysis-0.1.1.tar.gz

Download URL edgar_analysis-0.1.1.tar.gz
Size 25.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4cc0799b66008534cc99189fcdd287c4c74f1ad0757fed087c50e137e3469c73
BLAKE2b-256 checksum
How to use checksums
b6a072f2026ce304e5abb4ecac4134d7300151c64af896108b980e5e755bb69d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / edgar_analysis-0.1.1-py3-none-any.whl

Download URL edgar_analysis-0.1.1-py3-none-any.whl
Size 28.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bcddf1ce5ab456f421a63e7901f274193624aa1fb3245806cc0c3808672690ee
BLAKE2b-256 checksum
How to use checksums
ee8b2cd46410e1e8a8c14c68ea87eef71d9a5b294e0352166e5940f11e51ca1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Security for edgar-analysis 0.1.1

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

0.1.1 This release

2 release files No provenance

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