Skip to main content
Horizon has full test coverage across both Rust and Python layers.

Running Tests

Test Coverage

Test Structure

Rust Tests

Rust tests (98 tests) cover the core engine, risk pipeline, order management, position tracking, exchange backends, feed system, persistence layer, contingent orders, and order amendment. Tests are located in #[cfg(test)] mod tests blocks within each source file.

Python Tests

Python tests (395 tests) cover the full SDK: engine creation, pipeline composition, exchange configuration, feed management, multi-exchange routing, risk behavior, backtesting, execution algorithms, advanced orders, and Prometheus metrics.

Writing Strategy Tests

Use the Engine directly for unit testing your strategy logic:

Testing with fills

Since Position has no Python constructor, build positions by processing fills:

Testing risk limits

Testing pipeline functions

Test pipeline functions in isolation with a mock context:

Testing with persistence

Test Tips

Use Engine(risk_config=RiskConfig(max_position_per_market=10000)) in tests to avoid hitting risk limits unintentionally.
  • Paper exchange is the default. No credentials needed for tests
  • engine.tick(market_id, mid_price) triggers paper matching
  • engine.process_fill(fill) injects fills without going through the exchange
  • Position snapshots require engine.positions() which returns from the live tracker, not the DB
  • The fills vector is capped at 1000 entries in the Engine