Skip to main content
tests/test_streaming_signals.py · chapter Tests and team tooling, file 7 · 156 lines · open in the repository

What it does

The streaming job’s per-ticker logic (src/streaming/signals.py), tested without Spark.

What is inside

  • WINDOW_DAYS · line 13
  • trading_days(start, n) · line 16: n weekdays from start, as ISO strings.
  • make_rows(days, seed, alpha, beta) · line 26: Rows whose stock return follows a known market model plus noise.
  • run_all(rows, events, ticker) · line 37: Feed every row in one batch with a watermark past all of them.
  • one_event(day, ticker) · line 115

What it checks

  • market model recovers known alpha and beta (line 44)
  • market model needs enough days (line 53)
  • rows wait for the watermark and come out in date order (line 58)
  • duplicates are skipped (line 73)
  • late rows give the same result as in order rows (line 81)
  • baseline skips the gap days and the future (line 98)
  • weekend event starts next trading day (line 119)
  • car uses one model fitted before the window (line 127)
  • ticker specific events apply to that ticker only (line 152)

Connections

Uses: src/common/study.py, src/streaming/__init__.py

Source

tests/test_streaming_signals.py