feat(data): extend market data provider with charts, fundamentals, and quant analysis
Adds a stock data cache layer and indicator helpers (MA/RSI/MACD), expands the MarketDataProvider interface with candles, fundamentals, related-data, and quant analysis, and threads tags + source attribution through the shared types. Updates affected agent tests. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -60,18 +60,19 @@ function analyzeEarnings(snapshot: StockSnapshot, now: Date): EarningsSignal {
|
||||
}
|
||||
|
||||
function analyzeValuation(snapshot: StockSnapshot): ValuationSignal {
|
||||
const stockPe = snapshot.pe;
|
||||
const peerPes = snapshot.peers.map((peer) => peer.pe).filter((pe) => Number.isFinite(pe) && pe > 0);
|
||||
if (!Number.isFinite(snapshot.pe) || snapshot.pe <= 0 || peerPes.length === 0) {
|
||||
if (!Number.isFinite(stockPe) || stockPe === undefined || stockPe <= 0 || peerPes.length === 0) {
|
||||
return { label: "unknown" };
|
||||
}
|
||||
|
||||
const peerAveragePe = round(peerPes.reduce((sum, pe) => sum + pe, 0) / peerPes.length, 2);
|
||||
const spreadPct = round((snapshot.pe - peerAveragePe) / peerAveragePe, 4);
|
||||
const spreadPct = round((stockPe - peerAveragePe) / peerAveragePe, 4);
|
||||
const label = spreadPct <= -0.15 ? "discount" : spreadPct >= 0.15 ? "premium" : "fair";
|
||||
|
||||
return {
|
||||
label,
|
||||
stockPe: snapshot.pe,
|
||||
stockPe,
|
||||
peerAveragePe,
|
||||
spreadPct
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user