Skip to main content
tests/test_eventstudy.py · chapter Tests and team tooling, file 8 · 105 lines · open in the repository

What it does

The batch event study (src/eventstudy/) on small hand-made data where the right answer is known in advance.

What is inside

  • STOCK · line 17: a made-up ticker, so the test does not depend on config/
  • make_master(n_days, jump_on, seed) · line 20: A stock that follows ret = ALPHA + BETA * market + tiny noise, plus JUMP on one day.
  • event(d, name) · line 34

What it checks

  • market model recovers alpha and beta (line 38)
  • market model needs enough days (line 45)
  • car is the jump on day zero (line 50)
  • weekend event starts on the next trading day (line 64)
  • early event has no model and late event is skipped (line 72)
  • output matches its contract (line 80)
  • clustered test treats each event date as one observation (line 86)
  • summary and trend tables match their contracts (line 96)

Connections

Uses: src/common/contracts.py, src/common/study.py, src/eventstudy/car.py, src/eventstudy/stats.py

Source

tests/test_eventstudy.py