Skip to content

feat: Build complete market data backend - #5

Merged
Musa24 merged 1 commit into
mainfrom
claude/issue-4-20260406-1338
Apr 6, 2026
Merged

feat: Build complete market data backend#5
Musa24 merged 1 commit into
mainfrom
claude/issue-4-20260406-1338

Conversation

@Musa24

@Musa24 Musa24 commented Apr 6, 2026

Copy link
Copy Markdown
Owner

Implements the full market data subsystem per planning/MARKET_DATA_DESIGN.md:

  • Abstract MarketDataSource interface (ABC)
  • GBM simulator with Cholesky correlated sectors and random events
  • Massive API REST poller (Polygon.io compatible)
  • In-memory PriceCache decoupling write/read frequency
  • SSE endpoint /api/stream/prices
  • Factory selecting simulator or Massive from MASSIVE_API_KEY
  • FastAPI app with lifespan wiring
  • 60+ unit tests across 6 test files

Closes #4

Generated with Claude Code

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>
@Musa24
Musa24 merged commit 1533592 into main Apr 6, 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