edgartools icon indicating copy to clipboard operation
edgartools copied to clipboard

[DATA] Financials.get_financial_metrics() returns quarter income figures beside year-to-date cash flows, with no period on any value, on Q2 and Q3 10-Qs whose cash flow is year-to-date only

Open synfonia-llc opened this issue 1 month ago • 4 comments

Data Quality Issue Details

Issue Type:

  • [ ] Incorrect financial values (wrong numbers)
  • [ ] Missing financial data (expected data not present)
  • [x] Calculation errors (formulas producing wrong results)
  • [x] Data inconsistency (different values for same metric)
  • [ ] Historical data problems (changes over time)

Environment

EdgarTools Version: main@2323d732 (reports 5.62.0); also compared on v5.62.0 (5068cc54), same output Python Version: 3.14 Operating System: Windows

Financial Data Details

Company/Ticker: AAPL and TSLA (repository fixtures tests/fixtures/xbrl/aapl/10q_2023 and tests/fixtures/xbrl/tsla) Form Type: 10-Q Filing Date/Period: Apple quarter ended 2023-07-01 (Q3 FY2023); Tesla quarter ended 2024-06-30 (Q2 2024) Statement Type: Income Statement and Cash Flow Statement

Specific Metric/Concept:

  • Financial line item: revenue, operating_income, net_income, operating_cash_flow, capital_expenditures and free_cash_flow in the dictionary returned by Financials.get_financial_metrics()
  • XBRL concept name: Not applicable (the defect is the period each value is taken from, not the concept)

Data Issue

Expected Value:

  • Amount: each metric labelled with the period it covers (start, end or duration), or all metrics for one common period on request. On Apple's Q3 FY2023 10-Q: revenue 81,797,000,000 for 2023-04-02 to 2023-07-01, and operating cash flow 88,945,000,000 for 2022-09-25 to 2023-07-01, each with its period.
  • Source: the filing's own facts; each value's period below was read from the start and end dates of the XBRL fact that carries it.
  • Page/section reference: the condensed consolidated statements of operations (three months) and of cash flows (nine months) in the 10-Q.

Actual Value from EdgarTools:

  • Amount: one flat dictionary with 3-month revenue, operating income and net income beside 9-month (Apple) or 6-month (Tesla) operating cash flow, capital expenditures and free cash flow. No key carries a start, end or duration. A ratio built from the dictionary divides a year-to-date amount by a quarter: free cash flow / revenue reads 0.98 for Apple.
  • How obtained: the code below, run offline against two repository fixtures.

Code to reproduce:

from edgar import set_identity
set_identity("Your Name [email protected]")

from pathlib import Path
import edgar
from edgar.xbrl import XBRL
from edgar.financials import Financials

# Two 10-Q fixtures in the repository whose cash-flow statement covers the year to date only:
# Apple, quarter ended 2023-07-01 (Q3 FY2023); Tesla, quarter ended 2024-06-30 (Q2 2024)
root = Path(edgar.__file__).resolve().parents[1] / "tests/fixtures/xbrl"
for name in ["aapl/10q_2023", "tsla"]:
    xbrl = XBRL.from_directory(root / name)
    metrics = Financials(xbrl).get_financial_metrics()
    facts = xbrl.facts.to_dataframe()
    facts = facts[facts["period_type"] == "duration"]
    print(name)
    for key in ["revenue", "operating_income", "net_income",
                "operating_cash_flow", "capital_expenditures", "free_cash_flow"]:
        value = metrics[key]
        hit = facts[facts["numeric_value"].abs() == abs(value or 0)]
        spans = sorted({f"{r.period_start} to {r.period_end}" for r in hit.itertuples()})
        print(f"  {key:22} {value!r:>16}  facts with this value: {spans or 'none (calculated)'}")
    print("  free_cash_flow / revenue =", round(metrics["free_cash_flow"] / metrics["revenue"], 2))

Output on main@2323d732:

aapl/10q_2023
  revenue                   81797000000.0  facts with this value: ['2023-04-02 to 2023-07-01']
  operating_income          22998000000.0  facts with this value: ['2023-04-02 to 2023-07-01']
  net_income                19881000000.0  facts with this value: ['2023-04-02 to 2023-07-01']
  operating_cash_flow       88945000000.0  facts with this value: ['2022-09-25 to 2023-07-01']
  capital_expenditures       8796000000.0  facts with this value: ['2022-09-25 to 2023-07-01']
  free_cash_flow            80149000000.0  facts with this value: none (calculated)
  free_cash_flow / revenue = 0.98
tsla
  revenue                   25500000000.0  facts with this value: ['2024-04-01 to 2024-06-30']
  operating_income           1605000000.0  facts with this value: ['2024-04-01 to 2024-06-30']
  net_income                 1478000000.0  facts with this value: ['2024-04-01 to 2024-06-30']
  operating_cash_flow        3854000000.0  facts with this value: ['2024-01-01 to 2024-06-30']
  capital_expenditures       5043000000.0  facts with this value: ['2024-01-01 to 2024-06-30']
  free_cash_flow            -1189000000.0  facts with this value: none (calculated)
  free_cash_flow / revenue = -0.05

v5.62.0 (5068cc54) prints the same lines.

Cross-Verification

Have you verified this issue with:

  • [ ] Multiple time periods for same company
  • [x] Multiple companies with same issue
  • [x] Direct SEC filing comparison
  • [ ] Other financial data sources

Affects multiple periods/companies?

  • Companies tested: AAPL and TSLA (above, on main@2323d732 and v5.62.0). Earlier, on main@25786d43: Golub Capital BDC Q2 FY2025 10-Q (net income covers 89 days, operating cash flow 181 days) and Netflix Q3 2024 10-Q (every value covers 91 days, because Netflix files a 3-month cash flow).
  • Time periods tested: Apple Q3 FY2023, Tesla Q2 2024, Golub Capital BDC Q2 FY2025, Netflix Q3 2024
  • Pattern observed: on a Q2 or Q3 10-Q whose cash-flow statement covers the year to date only, the income keys hold the quarter and the cash-flow keys hold the year to date. Where a filer also files a 3-month cash flow (Netflix), the same keys hold 3 months. So the same key holds 3 months for one filer and 6 or 9 months for another.

Expected Behavior

What should happen: Each metric returned by get_financial_metrics() carries the period it covers (start, end or duration), or the method accepts a request for one common period. A discrete quarter is derived only where the filing supports it; otherwise it is left unavailable, and a year-to-date amount is never relabelled as a quarter.

Data validation rules:

  • Should the value be positive/negative? Not applicable; each amount is right for its own period.
  • Expected magnitude/range? Not applicable.
  • Should it match specific calculations? free_cash_flow and any ratio taken from the dictionary should combine amounts of one period only.

Additional Context

  • Accounting basis. On Form 10-Q, comprehensive income is presented for the quarter and for the year to date, but cash flows for the year to date only (ASC 270-10-S99-1(c), Reg S-X 10-01(c), reached through ASC 270-10-S45-2). That is a minimum: the rule also allows trailing twelve-month statements and has a single-crop agricultural exception, and a filer may present more, as Netflix does with a 3-month cash flow. So the mix arises only where the cash flow is year-to-date only, not on every Q2 or Q3 10-Q. Each cash-flow amount belongs to the period its statement covers (ASC 230-10-10-1, 230-10-45-24). Each value is right for its own period; the defect is the unstated mix.
  • Code (main@2323d732).
    • _collect_financial_metrics (edgar/financials.py:1043-1085) calls each getter at offset 0 and returns 15 keys, none with a period.
    • Each getter picks its column on its own statement through _order_period_columns (edgar/financials.py:53-123), which takes the shortest duration at the latest end date (line 101). On the income statement that is the quarter; on a cash-flow statement with only year-to-date columns it is the year-to-date column.
    • get_free_cash_flow (edgar/financials.py:798-814) subtracts year-to-date capital expenditures from year-to-date operating cash flow.
  • Documentation. get_quarterly_financials() promises "quarterly data instead of annual" (edgar/entity/core.py:631-638). docs/guides/extract-statements.md (lines 262-274) presents the dictionary as all the standard metrics at once. The bundled financials skill (edgar/ai/skills/financials/skill.yaml, line 99) says get_financials() handles period alignment automatically. No page says the cash-flow values are year-to-date.
  • Public paths. Company(ticker).get_quarterly_financials().get_financial_metrics(), filing.obj().financials.get_financial_metrics(), Financials.extract(filing) and Financials(xbrl). TenQ.to_context() is not affected.
  • Related, separate code paths (not filed): stitched 10-Q columns keyed by bare end date, and FilingViewer.validate mixing periods.

Impact Assessment:

  • [ ] Minor (affects specific edge case)
  • [x] Moderate (affects common use cases)
  • [ ] Major (affects core financial calculations)
  • [ ] Critical (produces completely wrong results)

Data quality issues are high priority and will be verified against official SEC filings. Accuracy is fundamental to EdgarTools.

synfonia-llc avatar Oct 22 '26 13:10 synfonia-llc

Opened twice by mistake while filing today's batch; this is a duplicate of #1662, which stays open. Closing this one.

synfonia-llc avatar Oct 22 '26 14:10 synfonia-llc

Reopening: #1662 was closed as a duplicate of this one, so this issue now tracks the report.

synfonia-llc avatar Oct 23 '26 08:10 synfonia-llc

@dgunning, here is our current thinking on the root cause, proposed behavior, and coordination with other issues.

Root Cause:

Financials.get_financial_metrics() combines independently selected statement values without carrying their periods into the result. The inspected Apple and Tesla filings therefore return quarter income figures beside valid YTD cash-flow figures with no dates attached.

Proposed Behavior:

Recommend keyword-only include_periods=True to add a periods mapping while existing calls retain their numeric-or-None entries. Metadata must follow the successful source selection, preserve unknown periods as unknown, and retain valid same-period YTD free cash flow. Exact start and end dates determine comparable durations; a shared end date alone is insufficient. The choice between this opt-in and a changed default remains yours, since a nested mapping can affect consumers that iterate numerically.

Coordination:

Recommend a separate period-metadata PR after the return-contract decision deferred by #1795, coordinating with the existing getters. Keep #1729's debt numerator definition and #1741's stitched-column naming separate; #1662 is the closed duplicate.

Below, please find the full design document. Please let me know your thoughts.

Brian

Attachment: design-public.md, Proposal: exact periods for Financials metrics (#1656).

AI assistance: Codex; gpt-6.1-sol (High) reproduced the behavior, checked raw XBRL facts/contexts and wrote this comment; gpt-6-astra (Max) prepared the architecture; separate gpt-6-astra (Max) agents provided adversarial review and dedicated Financial Statement Analyst review of source fidelity and financial meaning.

synfonia-llc avatar Oct 27 '26 11:10 synfonia-llc

Thanks Brian, you read the code right. The built-in free cash flow takes operating cash flow and capex from the same column, and both ratios use balance sheet dates, so nothing the library computes itself mixes periods. The trouble starts when someone divides across the dictionary, and right now they have no way to see the dates.

I'll go with the keyword-only include_periods=True and leave the default return as it is. Since it only adds information, it doesn't need to wait for a major release. I'm planning it for 6.x, after 6.0 ships on November 9. If you want to take the PR, your design already covers what it needs.

dgunning avatar Nov 01 '26 17:11 dgunning