From 2a99e008e3e09cd32a6638032adaee9447c5bb50 Mon Sep 17 00:00:00 2001 From: Investor Flow Build Date: Mon, 29 Jun 2026 21:58:39 -0400 Subject: [PATCH] slice 4c (omlx/ornith-35): YFinanceAdapter candles 10y backfill + adjustments fetchOne --- app/server/src/adapters/YFinanceAdapter.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/server/src/adapters/YFinanceAdapter.ts b/app/server/src/adapters/YFinanceAdapter.ts index 9eafb1c..9917355 100644 --- a/app/server/src/adapters/YFinanceAdapter.ts +++ b/app/server/src/adapters/YFinanceAdapter.ts @@ -5,6 +5,7 @@ import type { CacheKey, TtlClass, Provenance, Quote, PriceCandle, SymbolMeta, TickerKind } from '../cache/CacheRepository.ts'; import { parseCacheKey } from '../cache/CacheRepository.ts'; import type { SourceFetch, FetchResult } from './SourceAdapter.ts'; +import { parseAdjustments } from './yfinance-adjustments.ts'; // Polite UA including operator contact (yfinance community norm; EDGAR requires similar). const OPERATOR_EMAIL = process.env.YF_OPERATOR_EMAIL ?? 'operator@example.com'; @@ -31,10 +32,15 @@ export class YFinanceAdapter implements SourceFetch { case 'candles': { const [symbol, timeframe] = id.split(':'); const interval = timeframeToInterval(timeframe); - const days = timeframe === '1wk' ? 365 : 95; // slice 1: recent range for sparkline; slice 4 backfills `max` + const days = timeframe === '1wk' ? 3650 : 3650; // permanent backfill (~10 years) const raw = await yf.chart(symbol, { period1: new Date(Date.now() - days * 86_400_000), interval }); return { value: parseCandles(raw), ttlClass: 'daily_permanent', provenance: { fetchedAt, sourceKind: 'yfinance', rawSourceId: `${symbol}:${timeframe}` } }; } + case 'adjustments': { + const symbol = id; + const raw = await yf.chart(symbol, { period1: new Date(Date.now() - 3650 * 86_400_000), interval: '1d' }); + return { value: parseAdjustments(symbol, raw), ttlClass: 'daily_permanent', provenance: { fetchedAt, sourceKind: 'yfinance', rawSourceId: `${symbol}:adjustments` } }; + } case 'symbol': { const raw = await yf.quoteSummary(id, { modules: ['summaryProfile'] }); return { value: parseSymbol(raw, id), ttlClass: 'symbol_meta', provenance: { fetchedAt, sourceKind: 'yfinance', rawSourceId: id } };