Skip to content

feat(updater): shared n-port reader, calendar dates, windowed history, ticker and new-fund checks - #87

Merged
daggerok merged 1 commit into
mainfrom
feat/shared-updater-blocks
Oct 26, 2026
Merged

daggerok merged 1 commit into
mainfrom
feat/shared-updater-blocks

Conversation

@daggerok

Copy link
Copy Markdown
Owner

What changed

The shared updater blocks of .claude/tools/etfs/etf-std (byte-identical, applied with apply-block.ts, the current nport-reader template with the EDGAR state-suffix fix), wired like Schwab #75

  • nport-reader (ETF-H2): N-PORT holdings come from readNportHoldings with one SEC state per run (resetSecState()), the series id from SEC's company_tickers_mf.json (parseSecFundTickers) and tickers from nportTickers with SEC's company names (parseSecCompanyNames). The sheet keeps the WisdomTree headers (nportCell and nportIdentifier)
    • the old copy read the .txt submission through the series Atom feed, took only the first feed entry, built the archive folder from the accession prefix (the filer agent), accepted a filing whose series id was missing, replaced the published sheet on >= its date, wrote 0 for a missing weight or value, published CUSIP 000000000 as the identifier and gave every row a name-matched ticker
    • now: newest report period first from the WisdomTree Trust's own folder (primary_doc.xml), only the fund's own series, strictly newer than the published N-PORT sheet, missing numbers empty, the position's own identifier (ISIN or other id instead of 000000000), a ticker only for a U.S. equity in USD and never on two securities
    • WT-2 ticker hygiene: bonds, MBS/ABS, FX forwards and other derivatives no longer take an issuer or counterparty ticker (6,365 published rows have one today, 6,233 of them debt), Tokyo or other non-USD listings no longer take an OTC ADR ticker (DXJ FANUF)
    • freshness choice: the published N-PORT sheet is what a filing is compared with. A published product-page top-N list (WSPC, BTCW) is no full schedule: the first N-PORT filing replaces it whatever its date (the issuer dates that list every day, so a strict date check would block N-PORT forever)
    • product-page top holdings use the same SEC name key (nportNameKey, EDGAR suffixes like /DE/ dropped); the old normalizer and company map are gone
  • holdings-guard (Q24): holdingsWeightCount(publishedHeaders, publishedRows) as the 5th argument at both guard calls, so even the relaxed WSPC cannot replace numeric published weights with an all-blank sheet; HOLDINGS_GUARD_RELAX is exported for the test
  • windowed-chart (Q25): a HISTORY_RANGE window is merged with the published history and older distributions (the published [Ex-Date, ..., Total Distribution] rows are mapped to [date, amount]); a window that does not join keeps the published history (the old copy shrank the history to the window)
  • calendar-dates: toIsoDate is calendarIso(raw) ?? raw (the old copy went through Date.parse, a UTC suffix kept month names on the right day, but a timestamp with an offset such as 2026-10-24T22:00:00-07:00 became the 25th)
  • young-fund rule: withoutYoungReturns with { yr1, cagr3y, cagr5y, cagr10y, siAnn } on the official month-end and quarter-end tables (main, NAV and index rows) and on the final returns. The old copy nulled only since inception, below 365 days. Now the calendar anniversary, inclusive, every horizon; the age counts from the earliest known start (catalog inception, Yahoo first trade, first history day) so GCC (joined WisdomTree in 2020, trades since 2008) keeps its official 10-year return. The "derived since inception only from a series that starts at inception" part of fix(metrics): since-inception never annualized below one year or from a history window #86 stays (annualizedSince)
  • fund-selection (Q27, Q28): assertKnownTickers after the catalog load (live catalog plus published funds; the old check also accepted stale catalog-only rows), previous rows enter the catalog only with dataFile, the index map drops stale catalog-only rows (withoutStalePlaceholders). The pre-run NEW FUNDS line (every live ticker missing from the index, also failed reads) is replaced by newFundsLines(newFundsReport(previous, final)) after the index is written, in the log and as ### NEW FUNDS in the step summary. DROPPED FUNDS stays (now only funds with published data)
  • README: N-PORT source and identity, freshness, identifiers and tickers, empty missing values, young-fund rule, calendar dates, NEW FUNDS semantics, TICKERS and HISTORY_RANGE rows

Values that change on the next runs

  • N-PORT sheets: every published fund keeps its sheet until SEC has a strictly newer report period (today all 92 N-PORT funds are as of 2026-05-31 or 2026-06-30, the same as their newest filing). With the next filing per fund: empty instead of 0 (102 rows), own identifiers instead of 000000000 (17,576 rows), no ticker on 6,365 non-equity rows and on non-USD equities, weights at most 8 decimals, Shares Held without trailing zeros, Coupon/Maturity on every row of a debt sheet
  • WSPC and BTCW keep the top-N list until a first N-PORT filing exists (WSPC: none yet, BTCW: not in SEC's fund table); WSPC gains LHX for L3Harris from the new name key
  • Young-fund rule: WQTM loses its official 1-year (1.21) and GTR its official 5-year (4.22, 4.98 years old at the 2026-09-30 table); 8 funds younger than a year (GDT NTSD WAMA WDIG WDRN WIMA WSPC WTLS) lose since inception, which fix(metrics): since-inception never annualized below one year or from a history window #86 already does on their next run

How it was checked

  • bun test: 57 pass / 400 expects on main -> 65 pass / 428 expects, exit 0; the same with the config controls exported, exit 0
  • each new test fails with its wiring reverted (dates, both age-rule applications, earliest start, N-PORT names, top-N freshness, window merge, guard weights, Q27 assert and stale rows, Q28 lines, published date)
  • bun build --target=bun scripts/update-data.ts --outfile=/dev/null, bun build --target=bun src/main.tsx --outfile=/dev/null, git diff --check
  • check-readme.ts, check-scripts.ts, apply-block.ts --check holdings-guard,nport-reader,windowed-chart,fund-selection: ok, all five blocks identical
  • tc/check.sh: 64 -> 52 error lines (all pre-existing [ide] kinds, no new kind)
  • real runs (REQUEST_SLEEP=0, VERBOSE=true), then git checkout -- api/ && git clean -fd api/:
    • TICKERS="DGRW USFR": both unchanged, both log N-PORT ... is not newer than the published holdings
    • N-PORT path with api/wisdomtree/funds/{DXJ,SHAG} removed: DXJ rebuilt from accession 0000940400-26-036274 (2026-06-30, 439 rows, weight sum 104.56, 0 000000000), SHAG from 0000940400-26-028881 (2026-05-31, 1,190 rows, weight sum 99.52); rows with a ticker on non-equity or debt rows 687 -> 0, all equity tickers of DXJ (Tokyo listings) dropped; USFR in the same run not newer
    • N-PORT path with funds/DGRW removed: 198 rows, weight sum 99.97, 197 U.S. tickers (171 on the published first page before), 0 on non-equity rows
    • HISTORY_RANGE=1y TICKERS="DGRW USFR": zero diff, history rows 3,377 and 3,200 kept
    • TICKERS="GCC WQTM DGRW": GCC and DGRW unchanged, WQTM 1-year and since inception nulled

…, ticker and new-fund checks

Shared nport-reader, holdings-guard previousWeights, windowed-chart, calendar-dates and fund-selection blocks; WT-2: N-PORT tickers only for U.S. equities in USD (debt and derivative rows keep '-'); young-fund rule by calendar anniversary from the earliest known start
@daggerok
daggerok merged commit 9914f8d into main Oct 26, 2026
1 check passed
@daggerok
daggerok deleted the feat/shared-updater-blocks branch October 26, 2026 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant