Metadata-Version: 2.4
Name: edgar_agent_tool
Version: 1.1.0
Summary: A tool to read through filings on the EDGAR site from the SEC
Author-email: Kevin Bird <kevin@problemsolversguild.com>
License-Expression: Apache-2.0
Project-URL: Repository, https://github.com/problemsolversguild/edgar_agent_tool
Project-URL: Documentation, https://problemsolversguild.github.io/edgar_agent_tool
Keywords: sec,edgar,filings,finance,llm,agent,python
Classifier: Natural Language :: English
Classifier: Intended Audience :: Developers
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx>=0.24.0
Requires-Dist: html2text>=2020.1.16
Requires-Dist: cachetools>=5.0.0
Requires-Dist: beautifulsoup4>=4.11.0
Requires-Dist: lxml>=4.9.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: ruff>=0.4.0; extra == "dev"
Dynamic: license-file

# Edgar Agent Tool

> Structured access to SEC EDGAR filings (10-K, 10-Q, 8-K, 20-F, 13F-HR) with automatic section extraction — designed for LLM agents and financial analysis.

## Features

- 🔍 **Company Lookup** — Convert stock tickers or CIK strings to SEC CIK numbers
- 📑 **Filing Retrieval** — Fetch recent filings for any public company or institutional filer
- 🧩 **Automatic Section Parsing** — Extract specific sections (Risk Factors, MD&A, Financial Statements, etc.)
- 🌐 **Cross-Company Search** — Find filings across all companies by date range
- 🤖 **LLM-Friendly** — Clean markdown output, structured dictionary returns, designed for AI agents
- ⚡ **Smart Caching** — Built-in TTL caches to respect SEC rate limits

## Installation

```bash
pip install edgar-agent-tool
```

Or install from GitHub for the latest version:

```bash
pip install git+https://github.com/problemsolversguild/edgar_agent_tool.git
```

### Development Installation

```bash
pip install -e ".[dev]"
pytest
```

## Quick Start

First, set up your SEC User-Agent (required by the SEC):

```bash
export SEC_USER_AGENT="YourName your@email.com"
```

```python
from edgar_agent_tool.filings import get_filing, get_recent_filings

# Get Apple's latest 10-K with automatic section parsing
filing = get_filing("AAPL", filing_type="10-K")
print(filing["summary"])

# Extract a specific section (e.g., Risk Factors)
filing = get_filing("AAPL", filing_type="10-K", section="1A")
print(f"Risk Factors: {len(filing['section']['content'])} characters")

# Get a list of recent 8-K filings
filings = get_recent_filings("MSFT", filing_type="8-K", count=5)
for f in filings:
    print(f"{f['filingDate']}: {f['form']} - {f['primaryDocDescription']} - {f['items']}")
```

## Key Functions

| Function | Description |
|---|---|
| `get_filing(ticker, filing_type, index, section)` | Get a parsed filing with automatic section extraction |
| `get_recent_filings(ticker, filing_type, count)` | List recent filings for a company |
| `get_latest_filings(filing_type, start_date, end_date, count)` | Search filings across all companies |
| `ticker_to_cik(ticker)` | Convert ticker to SEC CIK number |
| `resolve_cik(identifier)` | Resolve ticker or CIK string to `(cik, label)` |
| `get_filing_document(url, as_md)` | Fetch raw filing content (optionally as markdown) |

## Filing Classes

For direct object-oriented control, use the typed filing classes:

| Class | Description |
|---|---|
| `Filing10K` | Annual reports with 23 standard items across 4 parts |
| `Filing10Q` | Quarterly reports with financial statements and MD&A |
| `Filing8K` | Current reports for material events (earnings, exec changes, etc.) |
| `Filing20F` | Annual reports for foreign private issuers |
| `Filing13F` | Institutional investment manager quarterly holdings reports (13F-HR) |

Each class provides:
- **Lazy content loading** — Content fetched only when accessed
- **Automatic section parsing** — Structured access to standard items or holdings
- **Convenience properties** — `.business`, `.risk_factors`, `.mda`, `.financials` (or `.holdings`, `.top_holdings`, `.total_value` on `Filing13F`)
- **Summary generation** — Human-readable filing overviews via `.summary()`

## Section Reference

### 10-K Sections
- **Item 1**: Business description
- **Item 1A**: Risk Factors ⭐
- **Item 7**: Management's Discussion & Analysis (MD&A) ⭐
- **Item 8**: Financial Statements ⭐

### 10-Q Sections
- **I-1** (or `1`): Financial Statements
- **I-2** (or `2`): MD&A ⭐
- **II-1A** (or `1A`): Risk Factor updates

### 8-K Items
- **1.01**: Material Definitive Agreement
- **2.02**: Results of Operations (earnings) ⭐
- **5.02**: Director/Officer changes
- **7.01**: Regulation FD Disclosure
- **8.01**: Other Events

### 20-F Sections
- **3.D**: Risk Factors ⭐
- **4.B**: Business Overview
- **5**: Operating and Financial Review (OFR) ⭐
- **18**: Financial Statements ⭐
