Stop substituting synthetic market data when providers fail

- Replace synthetic fallback in getQuote()/getPriceHistory() with null returns
- Add QuoteResult/PriceHistoryResult types with { value, stale } structure
- Implement stale-while-revalidate: return cached value with stale=true on live fetch failure
- Cache failures for 30s to avoid hammering provider
- Update CompanyAnalysis type to use PriceData<T> wrapper
- Update task-processors to track failed/stale tickers explicitly
- Update price-history-card UI to show unavailable state and stale indicator
- Add comprehensive tests for failure cases
- Add e2e tests for null data, stale data, and live data scenarios

Resolves #14
This commit is contained in:
2026-03-14 23:37:12 -04:00
parent 5b68333a07
commit 529437c760
10 changed files with 496 additions and 230 deletions

View File

@@ -205,7 +205,7 @@ async function buildCompanyAnalysisPayload(input: {
: null;
const companyProfile = toCompanyProfile(secProfile, description);
const valuationSnapshot = deriveValuationSnapshot({
quote: liveQuote,
quote: liveQuote.value,
sharesOutstanding: secProfile?.sharesOutstanding ?? null,
revenue: keyMetrics.revenue,
cash: keyMetrics.cash,
@@ -238,10 +238,10 @@ async function buildCompanyAnalysisPayload(input: {
tags: input.localInputs.watchlistItem?.tags ?? [],
cik: latestFiling?.cik ?? null
},
quote: liveQuote,
quote: { value: liveQuote.value, stale: liveQuote.stale },
position: input.localInputs.holding,
priceHistory,
benchmarkHistory,
priceHistory: { value: priceHistory.value, stale: priceHistory.stale },
benchmarkHistory: { value: benchmarkHistory.value, stale: benchmarkHistory.stale },
financials,
filings: redactedFilings.slice(0, 20),
aiReports,