Close the four outstanding market data gaps from MARKET_DATA_DESIGN.md - #4
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
last_trade.timestampdoesn't exist on the SDK's model (it'ssip_timestamp), and the divisor treated nanoseconds as milliseconds — together these meant the Massive path wrote nothing to the cache at all.PriceCache+GET /api/prices/{ticker}/historyso the main chart can backfill instantly.: pingevery 15s idle) so a Massive-backed feed's polling gaps don't read as a dead connection.TickerSnapshotmodel instead ofMagicMock.planning/MARKET_DATA_SUMMARY.mdto 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 verificationuv run --extra dev ruff check app/ tests/Generated with Claude Code
Closes #3