Skip to content

Complete the market data backend per planning docs - #3

Merged
cloudnote18-lab merged 1 commit into
mainfrom
claude/issue-2-20260903-2030
Sep 3, 2026
Merged

Complete the market data backend per planning docs#3
cloudnote18-lab merged 1 commit into
mainfrom
claude/issue-2-20260903-2030

Conversation

@cloudnote18-lab

Copy link
Copy Markdown
Owner

Implements the reviewed design in planning/MARKET_INTERFACE.md, planning/MARKET_SIMULATOR.md and planning/MASSIVE_API.md, fixing bugs documented in those docs: the Massive nanosecond timestamp bug, non-deterministic unknown-ticker seeds, mis-calibrated permanent price shocks, missing daily-change baseline, stale seed prices, no SSE heartbeat, no capability-aware source selection, and no chart-history backfill. Adds a capability-probing factory, an AnchoredSimulatorDataSource for free-tier Massive keys, and a substantially expanded mocked-only unit test suite.

Closes #2.

🤖 Generated with Claude Code

…RKET_SIMULATOR.md, MASSIVE_API.md

Implements the reviewed design for the market data subsystem, fixing bugs
identified in the project's own planning docs rather than leaving them latent:

- Massive client: fixed the nanosecond `sip_timestamp` field (was reading a
  nonexistent `.timestamp` in ms, silently swallowed by the exception
  handler), set retries=0 (SDK's default backoff is inside the same
  rate-limit window), classified rate-limit errors distinctly from bad
  responses, captured `prev_day.close` as the daily-change baseline, and
  surfaced tickers missing from a poll instead of dropping them silently.
- New capabilities.py: probes Massive entitlement once at startup, since a
  free/Basic-tier key authenticates but can't return any live price.
- New anchored.py: AnchoredSimulatorDataSource anchors the GBM simulator to
  real closing prices (one free-tier API call) for keys that are valid but
  not live-entitled, so a free key still produces a moving, realistic
  terminal instead of an empty watchlist.
- factory.py: now async and capability-probe-driven instead of routing on
  key presence alone; every branch returns a working source.
- Simulator: unknown-ticker seeds are now deterministic (hashed) instead of
  random per restart; random events are a decaying overlay instead of a
  permanent level shift (the old calibration inflated realized volatility
  ~20x); added a LinAlgError fallback and a 5-minute prefilled history ring
  buffer per ticker.
- models.py: PriceUpdate now carries a fixed session `open_price` baseline
  (change_today/change_percent_today) alongside the existing tick-to-tick
  change (renamed direction -> tick_direction); wire format is ISO 8601 UTC.
- stream.py: SSE heartbeat so idle connections (closed market, slow Massive
  poll) don't silently die at a proxy.
- MarketDataSource interface: added describe() (for /api/health) and
  get_history() (so charts aren't empty on first paint).
- Refreshed seed_prices.py to real closing prices (NVDA/NFLX were 3-7x off
  after 2024 splits).

Rewrote and substantially expanded the unit test suite across all of the
above (models, cache, interface, capabilities, simulator, simulator source,
massive client, anchored source, factory, SSE stream), including statistical
regression tests for the GBM calibration and the shock-decay fix. All Massive
API calls are mocked; no test touches the network.

Closes #2

Co-authored-by: cloudnote18-lab <290535093+cloudnote18-lab@users.noreply.github.com>
@cloudnote18-lab
cloudnote18-lab merged commit 28fbf99 into main Sep 3, 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.

Build complete market data backend.

1 participant