N-PORT cross-check: verify top candidates' actual holdings

fundlab/xcheck.py - for each screen candidate, resolve the fund's OWN
registrant CIK (browse-edgar; the 497-cover CIK is the family/trust),
get the exact series name for the ticker (the only reliable
disambiguator between sibling funds), walk the 4 most recent NPORT-P
filing dates, and parse holdings from the interactive NPORT XML
(primary_doc.xml at the accession root - NOT the XSL-rendered view the
submissions API points at). Exact seriesName match > best htm exhibit
parse. Buckets from the authoritative assetCat+issuerCat codes (ABS-O,
ABS-CBDO, DBT+UST/CORP/MUN/NUSS, LON, STIV, RA, EC+RF=fund, ...), not
position-name keywords. Resumable; raw filings cached under
nport_cache/raw/ (gitignored).

nport.py - _SECTION gains the "INVESTMENT PORTFOLIO (unaudited)"
variant (NPORT-EX Sch-F files); find_section/build gain a frac
token-tolerance param (Yahoo names drift from filing names); CMBS/ABS
bucket gains CLO/CBDO/DAC terms.

app Fund Lab - "N-PORT cross-check" expander: per-candidate table
(as-of, n, t5, top code-bucket, #1 position) + per-fund holdings
detail.

RESEARCH.md - cross-check verdicts. 21/22 resolved (qcmmrx is an MMF,
no holdings). The screen's top names are REAL:
- hmezx/mervx = genuine merger arb (equity in deal targets + escrow)
- egrix = 100% wrapper in one macro managed portfolio (underlying not
  NPORT-disclosed); etsix = fund of EV internal multi-strat accounts
- wmnux = discounted/zero-coupon corporate bonds + equity swaps (the
  "equity names" are bond issuers/swap underlyings)
- scfzx/rctix/aflix = securitized credit/CLO/distressed/levered loans
- hicox/fhmix/usmsx/btmix (munis), aguax/femdx (EM sovereign), anglx
  (agency MBS), lpxax (rotated out of prefs into bank/financial debt)
  = genuine missing-factor exposures the 35-sleeve model lacks
- fhcox/dultx/safex = short-duration carry (a short-duration sleeve
  would explain them)

tests/test_fundlab.py - test_xcheck (14 checks): parse_interactive,
code buckets, name-match normalization, series-name disambiguation.
Also: untrack fundlab/streamlit.log; gitignore raw/ + xcheck_run.log.

84 fundlab / 32 app / 14 data tests pass.
This commit is contained in:
gmp
2026-08-27 12:43:17 -04:00
parent f68b239b9a
commit a09861f39f
26 changed files with 8046 additions and 26 deletions
+71
View File
@@ -382,6 +382,76 @@ def test_curated() -> None:
all("seeks" in v["objective"].lower() for v in cur.values()))
def test_xcheck() -> None:
print("xcheck", flush=True)
import fundlab.xcheck as xc
xml = (
"<root><seriesName>Acme Global Macro Absolute Return Fund</seriesName>"
"<netAssets>1000000.00</netAssets>"
"<invstOrSecs>"
"<invstOrSec><name>Foo Corp 0%, Due 12/01/2029</name>"
"<title>Foo Corp 0%</title><valUSD>500000.00</valUSD>"
"<pctVal>50.0</pctVal><assetCat>DBT</assetCat>"
"<issuerCat>CORP</issuerCat></invstOrSec>"
"<invstOrSec><name>Bar ETF</name><title>Bar ETF</title>"
"<valUSD>300000.00</valUSD><pctVal>30.0</pctVal>"
"<assetCat>EC</assetCat><issuerCat>RF</issuerCat></invstOrSec>"
"<invstOrSec><name>UST 2yr</name><title>UST</title>"
"<valUSD>200000.00</valUSD><pctVal>20.0</pctVal>"
"<assetCat>DBT</assetCat><issuerCat>UST</issuerCat></invstOrSec>"
"</invstOrSecs></root>"
)
d = xc.parse_interactive(xml)
check("parse_interactive name", d is not None
and d["name"] == "Acme Global Macro Absolute Return Fund",
str(d and d.get("name")))
check("parse_interactive n positions", d is not None
and len(d["positions"]) == 3, str(d and len(d["positions"])))
check("parse_interactive net assets",
d is not None and abs(xc._fnum(d["net_assets"]) - 1e6) < 1e-6,
str(d and d.get("net_assets")))
check("parse_interactive non-NPORT -> None",
xc.parse_interactive("<a>b</a>") is None, "")
# code-based buckets
check("bucket DBT/UST", xc.xml_bucket({"asset_cat": "DBT",
"issuer_cat": "UST"})
== "US Treasury", "")
check("bucket DBT/CORP", xc.xml_bucket({"asset_cat": "DBT",
"issuer_cat": "CORP"})
== "Corporate bond", "")
check("bucket ABS-CBDO", xc.xml_bucket({"asset_cat": "ABS-CBDO",
"issuer_cat": "CORP"})
== "CLO (collateralized debt)", "")
check("bucket EC/RF = fund holding", xc.xml_bucket({"asset_cat": "EC",
"issuer_cat": "RF"})
== "Fund/ETF holdings", "")
check("bucket DE = derivative", xc.xml_bucket({"asset_cat": "DE",
"issuer_cat": "CORP"})
== "Derivative / hedge", "")
check("bucket STIV", xc.xml_bucket({"asset_cat": "STIV",
"issuer_cat": "RF"})
== "Cash/MMF (short-term)", "")
# name-match normalization
check("name match exact", xc._name_match(
"Cohen & Steers Low Duration Preferred and Income Fund, Inc.",
"Cohen & Steers Low Duration Preferred & Income Fund,Inc.") == 2, "")
check("name match containment", xc._name_match(
"Eaton Vance Global Macro Absolute Return Fund",
"Eaton Vance Global Macro Absolute Return Advantage Fund") == 1, "")
check("name match none", xc._name_match(
"NexPoint Merger Arbitrage Fund",
"NexPoint Event Driven Fund") == 0, "")
# series-name lookup from covers (cached)
t2c = xc.ticker_to_cik()
s = xc.series_name_for("EGRIX", "0000745463", t2c.get("egrix"))
check("series_name_for EGRIX disambiguates Advantage", s is not None
and s.endswith("Advantage Fund"), str(s))
def main() -> int:
test_pool()
test_text_and_objective()
@@ -393,6 +463,7 @@ def main() -> int:
test_universe()
test_overnight()
test_curated()
test_xcheck()
test_edgar_live()
print(f"\n{PASS} passed, {FAIL} failed")
return 1 if FAIL else 0