Behavioral Audit
The invariants the test suite proves hold
The test suite verifies properties that must be true across the pipeline. If any fail, a design bug is somewhere in the wiring.
Running the audit
bash
PYTHONPATH=. python3 -m pytest tests/test_behavioral_audit.py -v
Expected: 15 passed in ~0.1s
The invariants
Conservation
Beyond these invariants, the ledger enforces:
equity = initial_cash + realized_pnl + unrealized_pnl
at every tick. The metrics collector and the strategy’s ctx.portfolio.equity both read from the ledger, so there’s no risk of the two disagreeing.
Verified by TestConservation::test_equity_equals_cash_plus_unrealized.
Running the full suite
bash
PYTHONPATH=. python3 -m pytest tests/ -q
Expected output:
................................................................. [ 44%]
................................................................. [ 88%]
................... [100%]
163 passed in 0.29s
All 10 test modules, all 163 tests, green.