Skip to content

Fix Massive integration bug and close market data test gaps - #9

Merged
Sarita8888 merged 1 commit into
mainfrom
claude/market-data-fixes-20260818
Aug 18, 2026
Merged

Sarita8888 merged 1 commit into
mainfrom
claude/market-data-fixes-20260818

Conversation

@Sarita8888

Copy link
Copy Markdown
Owner

Summary

Addresses every issue raised in planning/MARKET_DATA_REVIEW.md:

  • §3.1 (High)massive_client.py read snap.last_trade.timestamp, which doesn't exist on the real Massive SDK's LastTrade dataclass, and divided by 1000 assuming milliseconds. This meant a valid MASSIVE_API_KEY never actually populated the cache. Fixed to use sip_timestamp / 1_000_000_000.0 (nanoseconds → seconds). Added a regression test built from a real TickerSnapshot.from_dict() payload instead of a MagicMock, so a future SDK-shape mismatch fails a test instead of failing silently in production.
  • §3.2 — Added a test that steps GBMSimulator with the full 10-ticker default watchlist, covering the real block-correlation matrix shape (not just the 1-2 ticker cases used elsewhere).
  • §3.3test_exception_resilience now actually injects a failure into GBMSimulator.step() and asserts the background loop survives and keeps updating the cache afterward.
  • §3.4_poll_once() now normalizes ticker casing like every other MassiveDataSource write path.
  • §3.5 — Documented the implementation-defined pre-start() behavior on MarketDataSource.add_ticker().
  • §3.7 — Added a concurrent-writer stress test for PriceCache using real OS threads.
  • Ran ruff format on the 5 previously-flagged whitespace-only files.

Test plan

  • uv run --extra dev pytest — 103/103 passing
  • uv run --extra dev pytest --cov=app — 98% coverage
  • uv run --extra dev ruff check app/ tests/ — clean
  • uv run --extra dev ruff format --check app/ tests/ — clean

🤖 Generated with Claude Code

Addresses every issue raised in planning/MARKET_DATA_REVIEW.md:

- §3.1 (High): massive_client.py used snap.last_trade.timestamp, which
  doesn't exist on the real SDK's LastTrade dataclass, and divided by
  1000 assuming milliseconds. Fixed to use sip_timestamp / 1e9
  (nanoseconds -> seconds). Added a regression test built from a real
  TickerSnapshot.from_dict() payload instead of a MagicMock, so a
  future SDK-shape mismatch fails a test instead of failing silently.
- §3.2: added a test that steps GBMSimulator with the full 10-ticker
  default watchlist, covering the real block-correlation matrix shape.
- §3.3: test_exception_resilience now actually injects a failure into
  GBMSimulator.step() and asserts the background loop survives and
  keeps updating the cache afterward.
- §3.4: _poll_once() now normalizes ticker casing like every other
  MassiveDataSource write path.
- §3.5: documented the implementation-defined pre-start() behavior on
  MarketDataSource.add_ticker().
- §3.7: added a concurrent-writer stress test for PriceCache using
  real OS threads.
- Ran ruff format on the 5 previously-flagged whitespace-only files.

103/103 tests passing, 98% coverage, ruff check and format clean.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Sarita8888
Sarita8888 merged commit 0427b28 into main Aug 18, 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.

1 participant