fix(sec): 13F-HR parser — guard zero total_value, preserve XML entities - #7620
Open
RadioOrc wants to merge 1 commit into
Open
fix(sec): 13F-HR parser — guard zero total_value, preserve XML entities#7620RadioOrc wants to merge 1 commit into
RadioOrc wants to merge 1 commit into
Conversation
Author
|
recheck |
RadioOrc
force-pushed
the
fix/13f-parser-empty-filing-and-entities
branch
from
July 31, 2026 10:41
08aafc2 to
c410120
Compare
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.
fix(sec): 13F-HR parser — guard zero total_value, preserve XML entities
Why
Two independent bugs in
openbb_sec/utils/parse_13f.py, both verified against live EDGAR filings (details + repro in the two linked issues):Empty filings crash. Managers with no reportable holdings file a single placeholder row (
value=0).total_valueis then 0,weight = 0/0 = NaN,.replace({nan: None})turns it intoNone, and the requiredweight: floatfield fails validation — the whole fetch raisesValidationError. Repro: CIK1562087(Thiel Macro), any quarter since 2025-Q4.&silently dropped from names. The parser soups the entire SGML-wrapped Complete Submission TXT, which is not well-formed XML; lxml recover mode drops character entities, soS&P500 EQL WGTbecomesSP500 EQL WGTwith no error. Every filer holding S&P ETFs is affected every quarter. Repro: CIK1536411(Duquesne), 2026-03-31.What
parse_13f_hr: extract the embedded well-formed<XML>blocks (form header + information table), strip their<?xml?>declarations and reassemble under a synthetic root before parsing — strict XML path, entities preserved. Bare-XML inputs pass through unchanged.parse_13f_hr: guard the weight division —weight = ... if total_value else 0.0.No public API change;
SecForm13FHRDatamodel untouched.Testing
Against live EDGAR (openbb-sec 1.6.6 == 1.6.7 ==
mainfor the affected lines):weight=0.0.&preserved (S&P500 EQL WGT,Ishares S&P Gsci Commodity-,State Str Spdr S&P 500 Etf T),sum(weight) == 1.0exactly, values/shares byte-identical to a direct parse of the standalone information-table XML.putCall, and a $1000s-convention filer) — field-level identical to an independent parser fed the standalone XML.Fixes #7618 and #7619.