Skip to content

Close the four outstanding market data gaps from MARKET_DATA_DESIGN.md - #4

Merged
GBRCenter merged 1 commit into
mainfrom
claude/issue-3-20260901-1437
Sep 2, 2026
Merged

Close the four outstanding market data gaps from MARKET_DATA_DESIGN.md#4
GBRCenter merged 1 commit into
mainfrom
claude/issue-3-20260901-1437

Conversation

@GBRCenter

Copy link
Copy Markdown
Owner

Summary

  • Fixes two real defects in the Massive REST client: last_trade.timestamp doesn't exist on the SDK's model (it's sip_timestamp), and the divisor treated nanoseconds as milliseconds — together these meant the Massive path wrote nothing to the cache at all.
  • Adds rolling price history to PriceCache + GET /api/prices/{ticker}/history so the main chart can backfill instantly.
  • Adds an SSE keepalive (: ping every 15s idle) so a Massive-backed feed's polling gaps don't read as a dead connection.
  • Adds ~34 new/updated unit tests, including rewriting Massive parsing tests to use the real TickerSnapshot model instead of MagicMock.
  • Updates planning/MARKET_DATA_SUMMARY.md to reflect the final state.

Closes the gaps recorded in planning/MARKET_DATA_DESIGN.md §0, except FastAPI lifespan wiring (gap 5), which depends on not-yet-built DB/portfolio/watchlist routes.

Test plan

  • cd backend && uv run --extra dev pytest -v — not run in this sandbox, needs verification
  • uv run --extra dev ruff check app/ tests/

Generated with Claude Code

Closes #3

The Massive REST client silently wrote nothing to the cache: it read
last_trade.timestamp (the real attribute is sip_timestamp) and divided
by 1000 instead of 1e9, so every snapshot was skipped by a blanket
except AttributeError. The parse loop is now _apply_snapshots(), tested
against the real TickerSnapshot model instead of MagicMock, which is
what let the original bug ship at 94% coverage.

Also adds the three other backend/app/market/ gaps the design doc
tracked as missing: a bounded rolling price history on PriceCache
(get_history, cleared on remove), the GET /api/prices/{ticker}/history
endpoint that serves it, and an SSE keepalive ping so a Massive-backed
feed's 15s polling gaps don't read as a dead connection.

Lifespan wiring (the design doc's fifth gap) is intentionally left out
-- it depends on the DB/portfolio/watchlist routes that are still to be
built per the root CLAUDE.md.

Co-authored-by: GBRCenter <225887058+GBRCenter@users.noreply.github.com>
@GBRCenter
GBRCenter merged commit 63f1623 into main Sep 2, 2026
1 check 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.

Construye el backend completo de Market Data

1 participant