Skip to content

Fix market data review findings and harden test suite#6

Open
kplayz wants to merge 1 commit intomainfrom
market-data-review-fixes
Open

Fix market data review findings and harden test suite#6
kplayz wants to merge 1 commit intomainfrom
market-data-review-fixes

Conversation

@kplayz
Copy link
Copy Markdown
Owner

@kplayz kplayz commented Apr 17, 2026

Summary

  • Fix flaky statistical tests: drift and correlation tests now suppress random events and use proper standard-error-based tolerances (both were deterministically failing)
  • Add thread safety to MassiveProvider: _tickers set now protected by threading.Lock, matching SimulatorProvider's pattern
  • Fix misleading docstring: PriceCache claimed "re-entrant lock" but uses non-reentrant threading.Lock
  • Add 5 new tests: remove-during-tick safety, price rounding verification, empty ticker set polling guard, and validate_ticker on 403/429 status codes

All findings from planning/MARKET_DATA_REVIEW.md. 63/63 tests passing, verified stable across multiple runs.

Test plan

  • uv run pytest tests/ -v passes 63/63 (up from 57/58 before fixes)
  • Ran test suite twice to confirm no flakiness
  • Drift test: verified tolerance is based on 5x standard error of the mean
  • Correlation test: verified measured correlation is ~0.16 (expected for 40% market factor)

🤖 Generated with Claude Code

- Fix drift test: suppress random events, read unrounded prices, use
  standard-error-based tolerance (was 1000x too tight)
- Fix correlation test: suppress random events that drown out the market
  factor signal (each event jump is ~750x a normal GBM tick)
- Add threading.Lock to MassiveProvider._tickers for thread safety
  parity with SimulatorProvider
- Fix PriceCache docstring claiming "re-entrant lock" (uses Lock, not RLock)
- Add tests: remove-during-tick safety, price rounding to 4 decimals,
  empty ticker set skips polling, validate_ticker on 403/429

63/63 tests passing, verified stable across multiple runs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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