Fix Massive integration bug and close market data test gaps - #9
Merged
Merged
Conversation
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>
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
Addresses every issue raised in
planning/MARKET_DATA_REVIEW.md:massive_client.pyreadsnap.last_trade.timestamp, which doesn't exist on the real Massive SDK'sLastTradedataclass, and divided by 1000 assuming milliseconds. This meant a validMASSIVE_API_KEYnever actually populated the cache. Fixed to usesip_timestamp / 1_000_000_000.0(nanoseconds → seconds). Added a regression test built from a realTickerSnapshot.from_dict()payload instead of aMagicMock, so a future SDK-shape mismatch fails a test instead of failing silently in production.GBMSimulatorwith the full 10-ticker default watchlist, covering the real block-correlation matrix shape (not just the 1-2 ticker cases used elsewhere).test_exception_resiliencenow actually injects a failure intoGBMSimulator.step()and asserts the background loop survives and keeps updating the cache afterward._poll_once()now normalizes ticker casing like every otherMassiveDataSourcewrite path.start()behavior onMarketDataSource.add_ticker().PriceCacheusing real OS threads.ruff formaton the 5 previously-flagged whitespace-only files.Test plan
uv run --extra dev pytest— 103/103 passinguv run --extra dev pytest --cov=app— 98% coverageuv run --extra dev ruff check app/ tests/— cleanuv run --extra dev ruff format --check app/ tests/— clean🤖 Generated with Claude Code