Skip to main content

The four layers

The packages

Rules

  1. The metric registry is the single source of predictor truth — serving layers import it, never duplicate it.
  2. MetricContext is the lookahead firewall: metric functions only see data with period_end <= t - asof_lag.
  3. Panels are batch artifacts — built on a schedule by python -m market_api.cli build-panel --all, read back by get_panel(), never computed on the request path.
  4. The REST layer maps endpoint → library function, converts exceptions to HTTP codes (LookupError → 404, ValueError → 400), and does nothing else.
  5. Production code budget: predictors stays under 500 lines.