Skip to content

Commit b3911ee

Browse files
ShengranYandgunningclaude
authored
Fix/issue 1824 6 k quarterly fallback (#1825)
* feat: add bounded HTML income fallback for quarterly 6-Ks Reuse EX-99 earnings tables when recent 6-Ks have no XBRL. Keep quarterly amounts separate from change columns and retain reporting currency, scale, source and caveats. Verify TSM 0001046179-26-000726: net income TWD 763,064 million and reported EPS NT$29.43. Preserve the 10-Q and XBRL paths. Fixes #1824 * fix(financials): align HTML DataFrame fields and parameters * refactor(financials): simplify 6-K income extraction * fix(6-K): add include_metadata to QuarterlyIncome; move upgrade note to 6.5 #2035 added include_metadata to Statement.to_dataframe(), so the signature-parity test failed once main was merged. QuarterlyIncome now takes it and drops the same five columns Statement does. 6.4.0 has shipped, so the upgrade note moves from 6.1.md to the current 6.5 guide. It now also records the 183-day cutoff: a 6-K filer whose latest XBRL 6-K is older than that got Financials in 6.4 and gets None now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Dwight Gunning <dgunning@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent fcf847e commit b3911ee

14 files changed

Lines changed: 1068 additions & 53 deletions

File tree

‎changelog.d/1824.added.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**Quarterly financials can read untagged 6-K income tables.** A bounded recent-filing search skips monthly notices; TSM's earnings release supplies TWD 763,064 million net income. (GH #1824)

‎docs/api/company.md‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -393,19 +393,25 @@ if financials:
393393

394394
### get_quarterly_financials()
395395

396-
Get financial statements from the latest 10-Q filing.
396+
Read the latest 10-Q or search recent unamended 6-Ks for quarterly results.
397397

398398
```python
399-
def get_quarterly_financials(self) -> Optional[Financials]
399+
def get_quarterly_financials(self, *, max_6k_filings: int = 10) -> Financials | QuarterlyIncome | None
400400
```
401401

402-
**Returns:** `Financials` object from latest quarterly report
402+
XBRL returns `Financials`. An eligible HTML earnings exhibit returns
403+
`QuarterlyIncome`, with income getters and an income table. The search
404+
examines at most `max_6k_filings` filings from the last 183 days and returns
405+
`None` if no supported quarterly result is available.
403406

404407
**Example:**
405408
```python
409+
from edgar import QuarterlyIncome
410+
406411
quarterly = company.get_quarterly_financials()
407-
if quarterly:
408-
q_income = quarterly.income_statement().to_dataframe()
412+
if quarterly is not None:
413+
income = quarterly if isinstance(quarterly, QuarterlyIncome) else quarterly.income_statement()
414+
q_income = income.to_dataframe()
409415
quarterly_revenue = quarterly.get_revenue()
410416
```
411417

‎docs/guides/financial-data.md‎

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,37 @@ income = quarterly.income_statement()
141141

142142
### Foreign private issuers (6-K)
143143

144-
A foreign private issuer such as TSMC files its annual report on Form 20-F with XBRL, so `get_financials()` works as usual. Its quarterly results arrive on Form 6-K, where the numbers sit in an HTML press release (an EX-99 exhibit) with no XBRL behind it. For those companies `get_quarterly_financials()` returns `None`, because there are no statements to read.
144+
When a company has no 10-Q, `get_quarterly_financials()` checks up to 10
145+
unamended 6-Ks filed in the last 183 days, newest first. Each filing's XBRL
146+
takes priority. An HTML earnings exhibit with identifiable quarterly columns
147+
and explicit units can supply a `QuarterlyIncome` result. A monthly notice
148+
alone cannot. The search limit can be set with `max_6k_filings`.
145149

146-
To get the quarter's figures, read the press release tables with `EarningsRelease`:
150+
```python
151+
from edgar import Company, Financials, QuarterlyIncome
152+
153+
quarterly = Company("TSM").get_quarterly_financials()
154+
if isinstance(quarterly, QuarterlyIncome):
155+
print(quarterly.get_net_income()) # Actual currency units
156+
print(quarterly.to_dataframe(include_unit=True))
157+
print(quarterly.source_url, quarterly.notes)
158+
elif isinstance(quarterly, Financials):
159+
print(quarterly.balance_sheet())
160+
```
161+
162+
The income table preserves the exhibit's period labels. A `period_offset`
163+
of 1 selects the next reported comparison column, which can be a year earlier.
164+
`to_dataframe()` scales monetary amounts to currency units and leaves per-share
165+
values as reported. Generic EPS has no inferred basic or diluted classification.
166+
When no supported filing is found, the method returns `None`.
167+
168+
To inspect a particular historical release and read the amounts in their
169+
original printed scale, use its accession:
147170

148171
```python
149-
from edgar import Company, find
172+
from edgar import find
150173
from edgar.earnings import EarningsRelease
151174

152-
Company("TSM").get_quarterly_financials() # None: TSMC's 6-Ks carry no XBRL
153-
154175
filing = find("0001046179-26-000726") # TSMC's 3Q26 earnings release, filed 2026-10-15
155176
release = EarningsRelease.from_filing(filing)
156177
release.income_statement.dataframe

‎docs/guides/sixk-data-object-guide.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ if six_k.financials:
151151
financials.cash_flow_statement
152152
```
153153

154-
Most earnings data in 6-K filings is in HTML tables inside EX-99.x exhibits, not in XBRL. To read those tables, use `EarningsRelease.from_filing(filing)` from `edgar.earnings`, which returns the press release's income statement and other tables as DataFrames. This is also why `Company.get_quarterly_financials()` returns `None` for most foreign private issuers.
154+
Most earnings data in 6-K filings is in HTML tables inside EX-99.x exhibits, not in XBRL. To read those tables, use `EarningsRelease.from_filing(filing)` from `edgar.earnings`, which returns the press release's income statement and other tables as DataFrames. For the latest quarterly result, `Company.get_quarterly_financials()` also checks recent 6-K earnings exhibits for an income table. See [Financial data](financial-data.md#foreign-private-issuers-6-k) for its return types.
155155

156156
---
157157

‎docs/upgrade/6.5.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,18 @@ see [Getting help](6.0.md#getting-help).
1717
| `xbrl.current_period.statement_of_equity()` | filtered to the period-end instant: the opening balance showed the closing one, and no flow rows (net income, dividends, buybacks) | the fiscal year's duration (the quarter in a 10-Q), with the opening balance from the prior period end | Apple FY2023 10-K 0000320193-23-000106: opening equity $62,146M → $50,672M; 8 rows → 24 (GH #429) |
1818
| `xbrl.current_period.cash_flow_statement()` on a 10-Q | the three-month duration | the year-to-date duration, as the 10-Q files it | Tesla Q2 2024 10-Q 0001628280-24-032662: 2 rows → 36 (GH #429) |
1919
| `current_period` statements' `get_dataframe()` and `as_statement=False`: an instant balance row under a duration | left out | the balance the rendered table shows: the opening or closing instant | Apple FY2023 10-K 0000320193-23-000106: cash flow gains beginning cash $24,977M and ending cash $30,737M (GH #429) |
20+
21+
### Quarterly financials
22+
23+
| Call | 6.4.0 | Now | Filing |
24+
|---|---|---|---|
25+
| `Company(...).get_quarterly_financials()` for a 6-K filer whose recent 6-Ks carry no XBRL | `None` | `QuarterlyIncome`, the income table from the earnings exhibit | TSMC 6-K 0001046179-26-000726: `None` → net income NT$763,064 million (GH #1824) |
26+
| `Company(...).get_quarterly_financials()` for a 6-K filer whose latest XBRL 6-K is more than 183 days old | `Financials` from that 6-K, however old | `None` | (GH #1824) |
27+
28+
`QuarterlyIncome` holds only the income statement. Call `result.to_dataframe()`
29+
to read it. Code that also needs a balance sheet or cash flow statement should
30+
check `isinstance(result, Financials)` first. The method now looks at 6-Ks filed
31+
in the last 183 days, at most `max_6k_filings` of them (10 by default), newest
32+
first, and XBRL wins over HTML. To read an older 6-K, call
33+
`edgar.earnings.EarningsRelease.from_filing(filing)` or `Financials.extract(filing)`
34+
on it directly. See the [6-K example](../guides/financial-data.md#foreign-private-issuers-6-k).

‎edgar/__init__.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"get_entity", "get_icon_from_ticker",
5454
),
5555
"edgar.filesystem": ("is_cloud_storage_enabled", "sync_to_cloud", "use_cloud_storage"),
56+
"edgar._html_financials": ("QuarterlyIncome",),
5657
"edgar.financials": ("Financials", "MultiFinancials"),
5758
"edgar.funds": ("Fund", "FundClass", "FundCompany", "FundSeries", "find_fund", "find_funds"),
5859
"edgar.funds.ncen": ("NCEN_FORMS", "FundCensus"),
@@ -165,7 +166,7 @@
165166
"ValidationError",
166167

167168
# -- Financial statements ------------------------------------------------
168-
"Financials", "MultiFinancials", "XBRL",
169+
"Financials", "MultiFinancials", "QuarterlyIncome", "XBRL",
169170

170171
# -- Funds ---------------------------------------------------------------
171172
"Fund", "FundCompany", "FundClass", "FundSeries",

0 commit comments

Comments
 (0)