edgartools icon indicating copy to clipboard operation
edgartools copied to clipboard

N-PORT: `SecurityLending.from_xml` reads a "Yes" cash-collateral answer as None, losing the collateral amount

Open mmitc opened this issue 1 month ago • 0 comments

Issue Type

  • [x] Data Quality Issue (incorrect financial values, missing data)
  • [ ] XBRL Parsing Issue (statement rendering, concept mapping)
  • [ ] Filing Access Issue (download failures, attachment problems)
  • [ ] Performance Issue (slow operations, memory problems)
  • [ ] Compatibility Issue (platform/dependency conflicts)
  • [ ] Documentation Issue (unclear instructions, missing examples)

Environment

EdgarTools Version: 5.62.0, and main at 8cd5799f Python Version: 3.12.13 Operating System: Windows 11

Bug Description

What you expected to happen: For N-PORT item C.12.a, a holding that answers Yes reads security_lending.is_cash_collateral == "Y", and its cash collateral amount is available.

What actually happened: It reads None. The filer writes a No as an element, <isCashCollateral>N</isCashCollateral>, but a Yes as an attribute on another element, <cashCollateralCondition isCashCollateral="Y" cashCollateralVal="..."/>. SecurityLending.from_xml (edgar/funds/reports.py) reads only the isCashCollateral element, so a Yes looks the same as a missing answer and cashCollateralVal is never read. The non-cash and loan-by-fund items use the same element-or-condition shape, so they are likely affected too (not checked).

On SGOV's N-PORT-P, 23 of 24 holdings read "N" and the one Yes holding (CUSIP 066922477, BlackRock Funds III, value $441,347,500.00) reads None.

Error message (if any):

None.

Reproduction

Company/Ticker: SGOV (iShares 0-3 Month Treasury Bond ETF) Time Period: period ended 2026-05-31 Relevant Forms: NPORT-P, accession 0002071691-26-016719 (also IVV, 0002071691-26-019760)

Minimal code to reproduce:

from lxml import etree
from edgar.funds.reports import SecurityLending

yes = etree.fromstring(b'<securityLending><cashCollateralCondition isCashCollateral="Y" '
                       b'cashCollateralVal="441347500.00"/></securityLending>')
print(SecurityLending.from_xml(yes).is_cash_collateral)   # None, expected "Y"

# Live, on the filing:
from edgar import set_identity, find
from edgar.funds.reports import FundReport
from collections import Counter
set_identity("Your Name [email protected]")
report = FundReport.from_filing(find("0002071691-26-016719"))
print(Counter(i.security_lending.is_cash_collateral for i in report.investments))
# Counter({'N': 23, None: 1})

Additional Context

Suggested fix: when the element is absent, read the isCashCollateral attribute of cashCollateralCondition (and keep cashCollateralVal as a new field), and the same for nonCashCollateralCondition and loanByFundCondition. Happy to send a PR with a regression test on SGOV.


Generated by Claude Code

mmitc avatar Oct 17 '26 01:10 mmitc