Skip to content

feat(demo): snapshot AAPL market data, serve in demo mode#242

Merged
luokerenx4 merged 1 commit into
masterfrom
feat/demo-market-aapl-snapshot
Jun 1, 2026
Merged

feat(demo): snapshot AAPL market data, serve in demo mode#242
luokerenx4 merged 1 commit into
masterfrom
feat/demo-market-aapl-snapshot

Conversation

@luokerenx4
Copy link
Copy Markdown
Contributor

Summary

The Market tab was empty in demo mode — every endpoint returned `{ results: null, error: "Demo mode — market data is not available." }`. This PR captures real AAPL data from Alice's own market-data layer and freezes it as JSON fixtures, so visitors can search AAPL and see a real-looking equity detail page.

Snapshot method

  1. `pnpm dev` → Alice on :47331 (FMP provider via in-process opentypebb — already configured with a working API key in `data/config/market-data.json`)
  2. curl 9 endpoints with `?symbol=AAPL`:
    • `/api/market/search?query=AAPL`
    • `/api/market-data-v1/equity/profile`
    • `/api/market-data-v1/equity/price/quote`
    • `/api/market-data-v1/equity/price/historical?interval=1d&start_date=…&end_date=…` (90-day window)
    • `/api/market-data-v1/equity/fundamental/{metrics,ratios,balance,income,cash}`
  3. Save raw JSON verbatim to `ui/src/demo/fixtures/market/`.

Going through-backend (vs hitting FMP directly) guarantees the response shape matches what the UI expects — no manual translation layer, no opentypebb-layer normalization to recreate.

Handler behavior

  • `symbol === 'AAPL'` → return the snapshotted payload
  • Any other symbol → `demoMarketEmpty` (`{results:null, provider:'demo', error:"Demo mode — only AAPL data is snapshotted. Install OpenAlice locally to query other symbols."}`) which the UI's existing empty-state branch renders cleanly. No silent wrong-symbol-shows-Apple-data failure mode.
  • Search matches `AAPL` / `apple` / any prefix of `apple inc.`

Verified

Check Result
`pnpm -F open-alice-ui exec tsc -b` clean
`pnpm -F open-alice-ui build` (prod) main chunk has 0 `Apple Inc` / `aapl-equity` / `demoMarketAAPL` / `312.06` matches. Single `MA50` match is a real-UI `QuoteHeader.tsx` column label, unrelated.
`pnpm dev:demo` + Playwright Search "AAPL" → dropdown shows "AAPL — Apple Inc. [EQUITY]" → click → renders price `312.06 -0.45 (-0.14%)`, full quote panel (open/prev/high/low/volume/mkt-cap/52w-high-low/MA50/MA200), 62-bar daily candle chart 2026-03-03→05-29, Profile + Key Metrics panels populated

Boundary touch

None — demo fixtures + handler only. The Alice backend was used to generate the fixtures but no production code modified.

Snapshot freshness

Date: 2026-05-29 (provider=FMP). When/if a UI contract change forces a re-snap, the same capture method works — boot Alice, curl with `?symbol=AAPL`, replace JSON files.

🤖 Generated with Claude Code

The Market tab in demo mode previously returned `{ results: null, error:
"Demo mode — market data is not available." }` for every endpoint —
visitors got an empty page. This wires up real AAPL data captured from
Alice's own market-data layer, frozen as JSON fixtures.

## Capture method

1. `pnpm dev` → Alice on :47331 (FMP provider via in-process
   opentypebb, already configured with a working API key)
2. curl 9 endpoints with `?symbol=AAPL`:
   - /api/market/search?query=AAPL
   - /api/market-data-v1/equity/profile
   - /api/market-data-v1/equity/price/quote
   - /api/market-data-v1/equity/price/historical?interval=1d&start_date=…&end_date=…
   - /api/market-data-v1/equity/fundamental/{metrics,ratios,balance,income,cash}
3. Save raw JSON responses verbatim to ui/src/demo/fixtures/market/.

Through-backend capture (rather than direct FMP) guarantees the
response shape matches whatever the UI expects, including any
opentypebb-layer normalization.

## Behavior

Handler returns the snapshot when `symbol === 'AAPL'`; for any other
symbol it returns `demoMarketEmpty` — a `{results:null, provider:
'demo', error:"Demo mode — only AAPL data is snapshotted. Install
OpenAlice locally to query other symbols."}` payload that the
UI's existing empty-state branch renders cleanly. No silent
"wrong-symbol-shows-Apple-data" failure mode.

Search matches `AAPL` / `apple` / any prefix of `apple inc.`.

## Verified

- pnpm -F open-alice-ui exec tsc -b: clean
- pnpm -F open-alice-ui build (prod): main chunk has zero `Apple Inc`
  / `aapl-equity` / `demoMarketAAPL` / `312.06` matches (single `MA50`
  match traces to real UI's QuoteHeader.tsx column label, unrelated)
- pnpm dev:demo + Playwright walk:
  - /market: search box prompts
  - type "AAPL": dropdown shows "AAPL — Apple Inc. [EQUITY]"
  - click: routes to /market/equity/AAPL, renders price 312.06 with
    -0.45 (-0.14%) change, full quote panel (open/prev/high/low/
    volume/mkt-cap/52w-high/52w-low/MA50/MA200), 62-bar daily candle
    chart 2026-03-03→05-29, Profile + Key Metrics panels populated

Snapshot date: 2026-05-29 (provider=FMP). Resnap if a UI contract
change forces it — same capture method works.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openalice-demo Ready Ready Preview, Comment Jun 1, 2026 4:09am

Request Review

@luokerenx4 luokerenx4 merged commit 07b6bcf into master Jun 1, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant