[BugFix] openbb-sec: Resolve per-share facts tagged only with share-class dimensions - #7660
Closed
liamthuynh wants to merge 1 commit into
Closed
liamthuynh wants to merge 1 commit into
liamthuynh wants to merge 1 commit into
Conversation
Member
|
Thanks for the PR @liamthuynh Can you check if the issue persists in the There is a v5 release in the works and it would be best if the bugfix is available there. |
…-class dimensions companyfacts carries undimensioned facts only, so `get_standardized_financials` returned None for `basic_eps`, `diluted_eps`, `weighted_ave_basic_shares_os` and `weighted_ave_diluted_shares_os` for issuers that tag them per share class — COKE since FY2019, Berkshire entirely, U-Haul's two-class method. Falls back to parsing the filing's extracted instance with `XBRLParser.parse_instance` and merging the class-dimensioned values before standardization. Share classes and the ticker-to-class map are read from each filing's cover page rather than hardcoded, because issuers move the same member between `StatementClassOfStockAxis` and `StatementEquityComponentsAxis` from one filing to the next. Basic counts are summed across classes; a senior class's diluted count is already as-converted and is not. Three cases cost real accuracy and are handled explicitly: sums are fail-closed, so a period whose members don't cover the full class set yields None rather than an understated total; filings merge newest-first so a restatement is never overwritten by the figures it restates (COKE's 10-for-1 split); and a period is skipped when the filing and companyfacts disagree on the share count, which would otherwise pair a post-split EPS with a pre-split denominator. Fetches through `openbb_sec.utils.cache.cached_request` — `aiohttp-client-cache` is not a dependency on this branch — and is income-statement-only, so balance sheet and cash flow requests skip the extra SEC calls. Refs OpenBB-finance#7645
liamthuynh
force-pushed
the
codex/sec-dimensioned-per-share-facts
branch
from
September 7, 2026 17:21
dcbac86 to
2de0720
Compare
Author
|
My pleasure @piiq ! Re-targeted this PR onto The bug is live on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request the OpenBB Platform
Description
Fixes #7645.
get_standardized_financialsreturnedNoneforbasic_eps,diluted_eps,weighted_ave_basic_shares_osandweighted_ave_diluted_shares_osfor issuers that tag those concepts only with share-class dimensions. The SEC companyfacts API carries undimensioned facts only, so the fields were empty even though every filing contains the values.Adds a fallback in the standardizer: for periods companyfacts does not cover, the filing's extracted instance is parsed with the existing
XBRLParser.parse_instanceand the class-dimensioned values are merged in beforeresolve_company_factsruns.Share classes are discovered per filing — from the cover page (
dei:EntityCommonStockSharesOutstanding), with tickers mapped viadei:TradingSymbol— and matched on the member, not the axis. That matters: U-Haul tags its voting class onStatementClassOfStockAxisin some quarters andStatementEquityComponentsAxisin others, and keying on the axis silently drops it.Per the issue's semantics, basic counts are summed across classes while a senior class's diluted count is taken as-converted and never summed (COKE FY2025 emits 83,807,000, not the ~94,000,000 a naive sum gives).
Safeguards, each found against live SEC data and covered by a test:
None, never to an understated total.fiscal_years=[2023]andfiscal_years=Nonereturn values 10x apart for the same year.IncomeLossFromContinuingOperationsPerBasicShare. The note'sUndistributed+Distributedpair cannot be summed — in a loss period the undistributed component is a positive magnitude with a negated presentation label, which overstated the result (0.28 vs a filed 0.18).The fallback is income-statement-only, so
get_standardized_financialsgained astatementhint and balance sheet / cash flow requests skip the extra SEC requests. No new dependencies.Scope: covers the three issuers in the issue. The discovery pieces are already issuer-agnostic, so generalizing is a natural follow-up PR. I'll raise two questions on the issue first — whether synthesized values should carry a distinguishable
source, and whetherweighted_ave_basic_shares_osshould be the cross-class sum or the requested class, since COKE and U-Haul use opposite conventions in their own tagging.How has this been tested?
openbb_platform/providers/sec/tests/test_dimensional_facts.py— 20 tests, no network. All pre-commit hooks pass.The issue's reproduction now returns
basic_eps 6.82 / diluted_eps 6.81(wasNone), and every value the issue quotes reproduces: COKE 2.39 with 66,564,000 basic shares (56,517,000 + 10,047,000); BRK-A 17,868/quarter; BRK-B 11.91/quarter; U-Haul's two-class method at 196,077,880.Populated per-share values, fallback disabled → enabled:
Regression check across 10 configurations (5 symbols × annual/quarterly, all three statements): no SEC-reported value changes and no row is lost — only the intended new rows appear. Single-class issuers (AAPL, MSFT, JNJ) are a no-op with zero extra HTTP requests.
Checklist