Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions scripts/update-data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,13 @@ describe('pipeline 7', () => {
await s.run({ HISTORY_RANGE: '1y' });
expect(s.snapshot()).toEqual(first);
expect(s.meta('AAA').history.totalRows).toBe(400);
// a truncated default-range (max) answer never shrinks the history either: one that joins the published days keeps them all,
// one of a new day that does not join keeps the fund as published
await s.run();
expect(s.snapshot()).toEqual(first);
s.handler = (url, init) => (url.includes('finance.yahoo.com') ? new Response(JSON.stringify(chartPayload(1, Date.UTC(2026, 9, 25)))) : base(url, init));
await s.run();
expect(s.meta('AAA').history.totalRows).toBe(400);
});

test('a relaxed guard still keeps numeric published weights from an all-blank N-PORT sheet (Q24)', async () => {
Expand Down
8 changes: 5 additions & 3 deletions scripts/update-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1797,11 +1797,13 @@ async function processFund(fund: CatalogFund, config: UpdaterConfig, previous: J
const query = yahooChartQuery(config.historyRange);
const payload = await fetchJson(`${YAHOO_CHART_URL}/${encodeURIComponent(fund.ticker)}?${query.toString()}`, `[ chart ] ${fund.ticker}`, config, { 'User-Agent': 'Mozilla/5.0' });
const fetched = parseChart(payload);
// A HISTORY_RANGE window never shrinks the published history (and with it 3y, 5y, 10y and since inception); the published
// A fresh chart never shrinks the published history (and with it 3y, 5y, 10y and since inception): a HISTORY_RANGE window, and
// also a truncated `max` answer (2026-10-29: Yahoo returned 2 bars for Franklin DVAL and USFI). A full `max` answer starts at
// inception: nothing older, unchanged. The published
// distributions table is [Ex-Date, ..., Total Distribution], the window merge reads [date, amount]
const publishedDistributions = (Array.isArray(previousMeta?.distributions?.rows) ? previousMeta.distributions.rows : []).map((cells: unknown) => (Array.isArray(cells) ? [cells[0], cells[cells.length - 1]] : cells));
chart = Number(query.get('period1')) > 0 ? mergeWindowedChart(fetched, previousRows, publishedDistributions) : fetched;
if (!chart) throw new Error(`chart window does not join the published history (${config.historyRange})`);
chart = mergeWindowedChart(fetched, previousRows, publishedDistributions);
if (!chart) throw new Error(`chart does not join the published history (${config.historyRange}, ${fetched.days.length} days)`);
days = chart.days;
fresh = fresh || days.length > 0;
} catch (error) {
Expand Down
Loading