You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add XBRL dataclass models and methods for fetching company facts
- Introduced `Fact` and `Facts` models in `edgar/models.py` to represent XBRL data points and structured company facts.
- Implemented `get_facts()` method in `Company` class to return a `Facts` model.
- Updated `Xbrl` class with `get_facts()` method for fetching structured facts by CIK.
- Enhanced `company_concepts()` and `frames()` methods to accept an optional `taxonomy` parameter.
- Added sample usage script `samples/use_xbrl_facts.py` demonstrating the new functionality.
- Created unit tests for `Fact` and `Facts` models in `tests/test_xbrl_facts.py`.
- Updated `CHANGELOG.md` to document the new features and changes.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
## [Unreleased]
9
9
10
10
### Added
11
+
12
+
-**edgar/models.py**: `Fact` and `Facts` XBRL dataclass models.
13
+
-`Facts` wraps the deeply nested `company_facts` JSON (4 levels) with `get(taxonomy, concept, unit=None)` returning a flat `list[Fact]` sorted by end date.
14
+
-`Facts.taxonomies` lists available namespaces (e.g. `['dei', 'us-gaap', 'ifrs-full']`).
15
+
-`Facts.concepts(taxonomy)` lists concept names within a taxonomy.
16
+
-`Facts.label()`, `Facts.description()`, `Facts.units()` for concept metadata.
17
+
-`Fact` wraps a single data point with `value`, `end`, `start`, `fiscal_year`, `fiscal_period`, `form`, `filed`, `frame` properties.
18
+
-**xbrl.py**: `get_facts(cik)` method returning a structured `Facts` model.
19
+
-**company.py**: `get_facts()` method returning a structured `Facts` model.
20
+
-**tests/test_xbrl_facts.py**: 39 unit tests for `Fact`, `Facts`, `Company.get_facts()`, `Xbrl.get_facts()`, and taxonomy parameter support.
21
+
22
+
### Changed
23
+
24
+
-**xbrl.py**: `company_concepts()` and `frames()` now accept an optional `taxonomy` parameter (default `"us-gaap"`). Previously hardcoded to `us-gaap`, now supports `"ifrs-full"`, `"dei"`, or any other taxonomy.
11
25
-**edgar/tickers.py**: New `Tickers` service for ticker/CIK/company name resolution via `sec.gov/files/company_tickers.json`.
12
26
-`resolve_ticker("AAPL")` → zero-padded CIK string (`"0000320193"`).
13
27
-`resolve_cik(320193)` → list of company entries (ticker, title, CIK).
@@ -38,19 +52,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
38
52
-**README.md**: Complete rewrite with hero example, full service table (15 services), usage examples for ticker resolution, fluent Company API, XBRL, filing search, downloads, response models, and badge row.
39
53
-**samples/use_company.py**: Sample file demonstrating the fluent Company interface (creation by ticker/CIK, filings, submissions, XBRL, download).
-**samples/use_xbrl_facts.py**: Sample file demonstrating `Facts` and `Fact` XBRL dataclass models (taxonomy browsing, concept retrieval, unit filtering, metadata, cross-taxonomy access).
41
56
-**tests/test_rate_limiter.py**: 9 unit tests for the sliding-window rate limiter (under-limit, at-limit sleep, timestamp expiry, integration checks for all three request paths).
42
57
43
58
### Changed
59
+
44
60
-**session.py**: Replaced counter-based rate limiter (`sleep 5s every 10 requests`) with a sliding-window algorithm using `collections.deque` of `time.monotonic()` timestamps. Sleeps only the minimum time needed when the 1-second window is full. `MAX_REQUESTS_PER_SECOND = 10` enforced per SEC policy.
45
61
-**session.py**: Rate limiting now applies to all three outgoing request paths (`make_request()`, `fetch_page()`, `download()`). Previously `fetch_page()` and `download()` bypassed rate limiting entirely.
46
62
47
63
### Changed
64
+
48
65
- Migrated from `setup.py` to `pyproject.toml` for modern packaging.
49
66
- Relaxed dependency version pins to use minimum ranges instead of exact versions.
50
67
- Updated minimum Python version to 3.9.
51
68
- Excluded `samples/` and `tests/` from distributed package.
52
69
53
70
### Fixed
71
+
54
72
-**enums.py**: Renamed `StateCodes` members from mixed-case (`Alabama`, `New_York`) to UPPER_CASE (`ALABAMA`, `NEW_YORK`) to follow Python enum naming conventions.
55
73
-**utils.py**: Exception chaining — `except ValueError as exc` / `raise ... from exc` in `parse_dates`.
56
74
-**session.py**: Replaced infinite retry loop with bounded retry (max 5) and exponential backoff.
@@ -90,11 +108,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
90
108
-**All examples**: Updated `EdgarClient()` → `EdgarClient(user_agent=...)` across 13 sample files, README.md, test file, and 55 docstring examples in 14 `edgar/` modules to reflect the required `user_agent` parameter.
91
109
92
110
### Removed
111
+
93
112
-**`edgar/parser/xbrl.py`**: Deleted `XbrlFiling` stub class — never imported or referenced.
94
113
-**`edgar/parser/`**: Removed empty directory that conflicted with `parser.py` module.
95
114
-**`edgar/enums.py`**: Replaced monolithic 1581-line file with `edgar/enums/` package — one module per enum class (`state_codes.py`, `country_codes.py`, `filing_type_codes.py`, `sic_codes.py`, `other_filing_types.py`) plus `__init__.py` re-exporting all names. All existing `from edgar.enums import X` imports continue to work.
96
115
97
116
### Added
117
+
98
118
-`py.typed` marker for PEP 561 type checker support.
99
119
-`CHANGELOG.md` to track version history.
100
120
-`.gitignore` file.
@@ -111,5 +131,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
111
131
## [0.1.6] - 2021-01-01
112
132
113
133
### Added
134
+
114
135
- Initial public release.
115
136
- EDGAR client with services: Archives, Companies, CurrentEvents, Datasets, Filings, Issuers, MutualFunds, OwnershipFilings, Series, Submissions, VariableInsuranceProducts, XBRL.
0 commit comments