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:
-
Yahoo Finance Data: The script retrieves the latest 4 years and 4 quarters of financial data for free.
-
Matching Process: When reporting dates overlap between SEC EDGAR and Yahoo Finance, the script aligns the data to map the correct accounting line items.
-
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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file edgar_analysis-0.1.0.tar.gz.
File metadata
- Download URL: edgar_analysis-0.1.0.tar.gz
- Upload date:
- Size: 25.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
818dec0f7355098930496b08f495b224298e8c72b30575666249e0aae6cb720e
|
|
| MD5 |
de6c1426efc76cd0b5ec79f2bfff2c98
|
|
| BLAKE2b-256 |
8fa5f42c20f744e30534d06db31e2742a4241915053e1d7db2af1c332f5d51e0
|
File details
Details for the file edgar_analysis-0.1.0-py3-none-any.whl.
File metadata
- Download URL: edgar_analysis-0.1.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0eacf6bb7f91f4c60b4e6843b5e814e5af38b85ebf9665c91afa1e1b396a888
|
|
| MD5 |
220d1c70293934f2118619b2428352e5
|
|
| BLAKE2b-256 |
2733859cbd5b30645cfc175dc95b68eeda397369526af2023c887da37b7ffb64
|