edgar-parser 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- edgar_parser-0.1.0/.gitignore +10 -0
- edgar_parser-0.1.0/LICENSE +21 -0
- edgar_parser-0.1.0/PKG-INFO +113 -0
- edgar_parser-0.1.0/README.md +93 -0
- edgar_parser-0.1.0/edgar_parser/__init__.py +4 -0
- edgar_parser-0.1.0/edgar_parser/config.py +35 -0
- edgar_parser-0.1.0/edgar_parser/earnings_8k.py +670 -0
- edgar_parser-0.1.0/edgar_parser/enrich.py +132 -0
- edgar_parser-0.1.0/edgar_parser/matching.py +1155 -0
- edgar_parser-0.1.0/edgar_parser/pipeline.py +2034 -0
- edgar_parser-0.1.0/edgar_parser/section_parser.py +680 -0
- edgar_parser-0.1.0/edgar_parser/tools.py +793 -0
- edgar_parser-0.1.0/edgar_parser/utils.py +626 -0
- edgar_parser-0.1.0/pyproject.toml +31 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Henry Chien
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: edgar-parser
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Structured financial data from SEC EDGAR filings — 10-Q, 10-K, and 8-K
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Requires-Dist: beautifulsoup4
|
|
9
|
+
Requires-Dist: lxml
|
|
10
|
+
Requires-Dist: numpy
|
|
11
|
+
Requires-Dist: openpyxl
|
|
12
|
+
Requires-Dist: pandas
|
|
13
|
+
Requires-Dist: python-dateutil
|
|
14
|
+
Requires-Dist: python-dotenv
|
|
15
|
+
Requires-Dist: rapidfuzz
|
|
16
|
+
Requires-Dist: requests
|
|
17
|
+
Provides-Extra: llm
|
|
18
|
+
Requires-Dist: anthropic; extra == 'llm'
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# edgar-parser
|
|
22
|
+
|
|
23
|
+
Structured financial data from SEC EDGAR filings.
|
|
24
|
+
|
|
25
|
+
Give your Python application access to income statements, balance sheets, cash flows, and qualitative sections from 10-Q, 10-K, and 8-K filings — parsed directly from SEC EDGAR with no third-party data vendor required.
|
|
26
|
+
|
|
27
|
+
This isn't a raw EDGAR scraper. The library handles XBRL namespace resolution, fiscal period matching, current vs. prior period alignment, sign normalization, and fuzzy metric lookup — so you get clean, analysis-ready data.
|
|
28
|
+
|
|
29
|
+
## What it does
|
|
30
|
+
|
|
31
|
+
**Core Extraction** (`parse_filing`)
|
|
32
|
+
- Parses iXBRL facts from 10-Q and 10-K filings on SEC EDGAR
|
|
33
|
+
- Resolves XBRL namespaces, units, scales, and dimensional qualifiers
|
|
34
|
+
- Enriches facts with presentation roles and negated-label sign flipping
|
|
35
|
+
|
|
36
|
+
**Period Matching** (`match_filing`)
|
|
37
|
+
- Aligns current and prior period values for each financial line item
|
|
38
|
+
- Handles quarterly, full-year, and 4Q (derived annual) modes
|
|
39
|
+
- Zip-matching with adaptive fallback to fuzzy matching for edge cases
|
|
40
|
+
|
|
41
|
+
**8-K Earnings Extraction** (`earnings_8k`) — *optional, requires `anthropic`*
|
|
42
|
+
- Extracts financial data from 8-K earnings press releases using Claude
|
|
43
|
+
- Automatic fallback when 10-Q/10-K is not yet available for a period
|
|
44
|
+
- Same output schema as core extraction for seamless integration
|
|
45
|
+
|
|
46
|
+
**Filing Sections** (`section_parser`)
|
|
47
|
+
- Parses qualitative sections from 10-K/10-Q filings (Risk Factors, MD&A, Business, etc.)
|
|
48
|
+
- Summary and full-text modes with configurable word limits
|
|
49
|
+
|
|
50
|
+
**High-Level Tools** (`tools`)
|
|
51
|
+
- `get_financials(ticker, year, quarter)` — all facts for a filing period
|
|
52
|
+
- `get_filings(ticker, year, quarter)` — list available filings (10-Q, 10-K, 8-K)
|
|
53
|
+
- `get_metric(ticker, year, quarter, metric_name)` — single metric lookup with fuzzy matching
|
|
54
|
+
- `get_filing_sections(ticker, year, quarter)` — qualitative section text
|
|
55
|
+
|
|
56
|
+
## Install
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install edgar-parser
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
For 8-K earnings extraction (uses Claude API):
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pip install "edgar-parser[llm]"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Quick start
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from edgar_parser.tools import get_financials, get_metric
|
|
72
|
+
|
|
73
|
+
# Get all financial facts from Apple's Q1 2025 10-Q
|
|
74
|
+
result = get_financials("AAPL", 2025, 1)
|
|
75
|
+
for fact in result["facts"][:5]:
|
|
76
|
+
print(f"{fact['metric']}: {fact['current_value']}")
|
|
77
|
+
|
|
78
|
+
# Look up a single metric
|
|
79
|
+
revenue = get_metric("AAPL", 2025, 1, "Revenue")
|
|
80
|
+
print(f"Revenue: {revenue['value']} {revenue['unit']}")
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Or use the lower-level API for more control:
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
from edgar_parser import parse_filing, match_filing
|
|
87
|
+
|
|
88
|
+
# Parse raw XBRL facts
|
|
89
|
+
parsed = parse_filing("AAPL", 2025, 1, full_year_mode=False)
|
|
90
|
+
|
|
91
|
+
# Match current vs. prior periods
|
|
92
|
+
matched = match_filing(parsed)
|
|
93
|
+
print(matched.head())
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Key functions
|
|
97
|
+
|
|
98
|
+
| Function | Module | Description |
|
|
99
|
+
|----------|--------|-------------|
|
|
100
|
+
| `get_financials` | `tools` | All facts for a ticker/period, with caching |
|
|
101
|
+
| `get_filings` | `tools` | List SEC filings (10-Q, 10-K, 8-K) for a period |
|
|
102
|
+
| `get_metric` | `tools` | Single metric lookup with fuzzy matching |
|
|
103
|
+
| `get_filing_sections` | `tools` | Qualitative section text (Risk Factors, MD&A, etc.) |
|
|
104
|
+
| `parse_filing` | `pipeline` | Low-level XBRL fact extraction |
|
|
105
|
+
| `enrich_filing` | `pipeline` | Fiscal period categorization and enrichment |
|
|
106
|
+
| `match_filing` | `matching` | Current vs. prior period alignment |
|
|
107
|
+
| `find_8k_for_period` | `earnings_8k` | Find 8-K earnings release for a fiscal period |
|
|
108
|
+
|
|
109
|
+
## Requirements
|
|
110
|
+
|
|
111
|
+
- Python 3.10+
|
|
112
|
+
- No API key needed — data comes directly from SEC EDGAR (public)
|
|
113
|
+
- Optional: `ANTHROPIC_API_KEY` environment variable for 8-K extraction
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# edgar-parser
|
|
2
|
+
|
|
3
|
+
Structured financial data from SEC EDGAR filings.
|
|
4
|
+
|
|
5
|
+
Give your Python application access to income statements, balance sheets, cash flows, and qualitative sections from 10-Q, 10-K, and 8-K filings — parsed directly from SEC EDGAR with no third-party data vendor required.
|
|
6
|
+
|
|
7
|
+
This isn't a raw EDGAR scraper. The library handles XBRL namespace resolution, fiscal period matching, current vs. prior period alignment, sign normalization, and fuzzy metric lookup — so you get clean, analysis-ready data.
|
|
8
|
+
|
|
9
|
+
## What it does
|
|
10
|
+
|
|
11
|
+
**Core Extraction** (`parse_filing`)
|
|
12
|
+
- Parses iXBRL facts from 10-Q and 10-K filings on SEC EDGAR
|
|
13
|
+
- Resolves XBRL namespaces, units, scales, and dimensional qualifiers
|
|
14
|
+
- Enriches facts with presentation roles and negated-label sign flipping
|
|
15
|
+
|
|
16
|
+
**Period Matching** (`match_filing`)
|
|
17
|
+
- Aligns current and prior period values for each financial line item
|
|
18
|
+
- Handles quarterly, full-year, and 4Q (derived annual) modes
|
|
19
|
+
- Zip-matching with adaptive fallback to fuzzy matching for edge cases
|
|
20
|
+
|
|
21
|
+
**8-K Earnings Extraction** (`earnings_8k`) — *optional, requires `anthropic`*
|
|
22
|
+
- Extracts financial data from 8-K earnings press releases using Claude
|
|
23
|
+
- Automatic fallback when 10-Q/10-K is not yet available for a period
|
|
24
|
+
- Same output schema as core extraction for seamless integration
|
|
25
|
+
|
|
26
|
+
**Filing Sections** (`section_parser`)
|
|
27
|
+
- Parses qualitative sections from 10-K/10-Q filings (Risk Factors, MD&A, Business, etc.)
|
|
28
|
+
- Summary and full-text modes with configurable word limits
|
|
29
|
+
|
|
30
|
+
**High-Level Tools** (`tools`)
|
|
31
|
+
- `get_financials(ticker, year, quarter)` — all facts for a filing period
|
|
32
|
+
- `get_filings(ticker, year, quarter)` — list available filings (10-Q, 10-K, 8-K)
|
|
33
|
+
- `get_metric(ticker, year, quarter, metric_name)` — single metric lookup with fuzzy matching
|
|
34
|
+
- `get_filing_sections(ticker, year, quarter)` — qualitative section text
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install edgar-parser
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
For 8-K earnings extraction (uses Claude API):
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install "edgar-parser[llm]"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Quick start
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from edgar_parser.tools import get_financials, get_metric
|
|
52
|
+
|
|
53
|
+
# Get all financial facts from Apple's Q1 2025 10-Q
|
|
54
|
+
result = get_financials("AAPL", 2025, 1)
|
|
55
|
+
for fact in result["facts"][:5]:
|
|
56
|
+
print(f"{fact['metric']}: {fact['current_value']}")
|
|
57
|
+
|
|
58
|
+
# Look up a single metric
|
|
59
|
+
revenue = get_metric("AAPL", 2025, 1, "Revenue")
|
|
60
|
+
print(f"Revenue: {revenue['value']} {revenue['unit']}")
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Or use the lower-level API for more control:
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from edgar_parser import parse_filing, match_filing
|
|
67
|
+
|
|
68
|
+
# Parse raw XBRL facts
|
|
69
|
+
parsed = parse_filing("AAPL", 2025, 1, full_year_mode=False)
|
|
70
|
+
|
|
71
|
+
# Match current vs. prior periods
|
|
72
|
+
matched = match_filing(parsed)
|
|
73
|
+
print(matched.head())
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Key functions
|
|
77
|
+
|
|
78
|
+
| Function | Module | Description |
|
|
79
|
+
|----------|--------|-------------|
|
|
80
|
+
| `get_financials` | `tools` | All facts for a ticker/period, with caching |
|
|
81
|
+
| `get_filings` | `tools` | List SEC filings (10-Q, 10-K, 8-K) for a period |
|
|
82
|
+
| `get_metric` | `tools` | Single metric lookup with fuzzy matching |
|
|
83
|
+
| `get_filing_sections` | `tools` | Qualitative section text (Risk Factors, MD&A, etc.) |
|
|
84
|
+
| `parse_filing` | `pipeline` | Low-level XBRL fact extraction |
|
|
85
|
+
| `enrich_filing` | `pipeline` | Fiscal period categorization and enrichment |
|
|
86
|
+
| `match_filing` | `matching` | Current vs. prior period alignment |
|
|
87
|
+
| `find_8k_for_period` | `earnings_8k` | Find 8-K earnings release for a fiscal period |
|
|
88
|
+
|
|
89
|
+
## Requirements
|
|
90
|
+
|
|
91
|
+
- Python 3.10+
|
|
92
|
+
- No API key needed — data comes directly from SEC EDGAR (public)
|
|
93
|
+
- Optional: `ANTHROPIC_API_KEY` environment variable for 8-K extraction
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# coding: utf-8
|
|
3
|
+
|
|
4
|
+
from dotenv import load_dotenv
|
|
5
|
+
load_dotenv()
|
|
6
|
+
|
|
7
|
+
# === CONFIG & SETUP ==========================================
|
|
8
|
+
|
|
9
|
+
# === HEADERS ======
|
|
10
|
+
HEADERS = {
|
|
11
|
+
"User-Agent": "edgar-parser (Python library; github.com/henrysouchien/edgar-parser)",
|
|
12
|
+
"Accept-Encoding": "gzip, deflate",
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
TICKER_CIK_URL = "https://www.sec.gov/files/company_tickers.json"
|
|
16
|
+
|
|
17
|
+
# === NUMBER OF FILINGS TO PULL ======
|
|
18
|
+
N_10Q = 12
|
|
19
|
+
N_10K = 4
|
|
20
|
+
|
|
21
|
+
# === EXTRA FILING PULLS ===
|
|
22
|
+
N_10Q_EXTRA = 0
|
|
23
|
+
N_10K_EXTRA = 0
|
|
24
|
+
|
|
25
|
+
# === SAFE LIMIT TIMES ===
|
|
26
|
+
REQUEST_DELAY = 1 # in seconds
|
|
27
|
+
|
|
28
|
+
# === EXPORTS ===
|
|
29
|
+
OUTPUT_METRICS_DIR = "metrics"
|
|
30
|
+
EXPORT_UPDATER_DIR = "exports"
|
|
31
|
+
|
|
32
|
+
# 8-K earnings release extraction
|
|
33
|
+
ANTHROPIC_MODEL_8K = "claude-sonnet-4-20250514"
|
|
34
|
+
MAX_8K_HTML_BYTES = 500_000
|
|
35
|
+
|