Skip to main content

A package for analyzing EDGAR financial statements for companies

Project description

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.

Project details


Download files

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

Source Distribution

edgar_analysis-0.1.1.tar.gz (25.9 kB view details)

Uploaded Source

Built Distribution

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

edgar_analysis-0.1.1-py3-none-any.whl (28.7 kB view details)

Uploaded Python 3

File details

Details for the file edgar_analysis-0.1.1.tar.gz.

File metadata

  • Download URL: edgar_analysis-0.1.1.tar.gz
  • Upload date:
  • Size: 25.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for edgar_analysis-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4cc0799b66008534cc99189fcdd287c4c74f1ad0757fed087c50e137e3469c73
MD5 cace6ba47195f329d0321e49d2bc86f8
BLAKE2b-256 b6a072f2026ce304e5abb4ecac4134d7300151c64af896108b980e5e755bb69d

See more details on using hashes here.

File details

Details for the file edgar_analysis-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: edgar_analysis-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 28.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for edgar_analysis-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bcddf1ce5ab456f421a63e7901f274193624aa1fb3245806cc0c3808672690ee
MD5 c29abf0582b874c415e5632515d5b22b
BLAKE2b-256 ee8b2cd46410e1e8a8c14c68ea87eef71d9a5b294e0352166e5940f11e51ca1d

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