CH Charles Hayes
← back to all projects

Stock Narrative Explorer

Interactive equity-narrative tool that generates confidence-tiered, day-by-day AI explanations for stock movements across a configurable watchlist, combining yfinance, Finnhub, SEC EDGAR, and Google News with daily drift detection.

Python FastAPI Anthropic API React/Vite Docker Railway

Problem

When a stock moves sharply, the explanations available in real time are usually low-quality: rumor-driven, single-source, or written hours after the move with the benefit of hindsight. I wanted a tool that could explain a day’s price action with the same standard I’d hold an internal incident review to: cite sources, separate signal from rumor, and be explicit about what it doesn’t know.

Approach

A daily pipeline pulls price data, news, regulatory filings, and macro context for a configurable watchlist (NVDA, MSFT and TSLA by default, plus any US ticker on demand). An AI layer generates a per-day narrative against a strict schema: the explanation must include a confidence tier, supporting sources, and an explicit “what’s missing” section. A drift-detection job re-evaluates older narratives when new information lands so they don’t go stale silently.

Architecture

  • Data layer: yfinance for prices, Finnhub for company news, SEC EDGAR for filings, Google News for surrounding press. All sources cached at the day level — re-runs are cheap.
  • AI layer: Anthropic API. Structured output enforced server-side; confidence tiers are not optional fields.
  • Backend: FastAPI, deployed via Docker on Railway. Daily cron triggers the pipeline; results land in a small SQLite store.
  • Frontend: React + Vite. Per-ticker timeline view, with the narrative, sources, and confidence tier visible together — no hidden citations.

Outcomes / What I learned

  • A good narrative requires forcing the model to admit ignorance — confidence tiers and “what’s missing” did more for quality than any prompt iteration.
  • The 30-day baseline + drift-detection job catches stale narratives more reliably than threshold alerts on raw price.
  • Caching at the day level kept Anthropic API costs low enough to run the full watchlist daily without budget anxiety.