feat: Build complete market data backend - #5
Merged
Conversation
Implements the full market data subsystem per MARKET_DATA_DESIGN.md: - `src/market/models.py` — PriceTick dataclass (slots=True) - `src/market/cache.py` — PriceCache (in-memory, asyncio-safe) - `src/market/interface.py` — MarketDataSource ABC - `src/market/simulator_engine.py` — GBM simulator with correlated sectors, Cholesky decomposition, and random events - `src/market/simulator.py` — SimulatorDataSource async wrapper with background tick loop - `src/market/massive.py` — MassiveDataSource REST poller (Polygon.io compatible) - `src/market/factory.py` — create_market_source() factory (env-var driven) - `src/market/sse.py` — SSE endpoint /api/stream/prices - `src/market/__init__.py` — public package exports - `src/main.py` — FastAPI app with lifespan wiring Unit tests (pytest + pytest-asyncio): - test_simulator_engine.py — GBM math, correlation matrix, add/remove tickers, determinism - test_cache.py — PriceCache CRUD operations - test_massive.py — response parsing, HTTP error handling, async start/stop - test_simulator.py — async start/stop, cache population, add/remove tickers - test_factory.py — env-var selection logic - test_sse.py — SSE response shape, event format, field validation Co-authored-by: Musa24 <Musa24@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.
Implements the full market data subsystem per
planning/MARKET_DATA_DESIGN.md:MarketDataSourceinterface (ABC)PriceCachedecoupling write/read frequency/api/stream/pricesMASSIVE_API_KEYCloses #4
Generated with Claude Code