Add algotrader 2.0: a backtester that tries to prove itself wrong
Claude
Unverified signature
3339913
Most backtesting tools answer "how much would this have made?". This adds a
second, harder question: how much of that was luck?
New `algotrader` package (additive — v1's agentic_ai_system, its tests, CI and
Docker setup are untouched):
- engine.py: vectorised backtester with an explicit no-look-ahead contract.
A strategy emits a target exposure at bar t's close; the engine holds
position[t] = target[t - lag] with lag >= 1, so a signal computed on a bar
cannot earn that bar's move. Costs are charged on exposure changes, plus a
borrow fee on shorts.
- validation/: the point of the release.
- permutation.py — Monte-Carlo permutation test. Shuffles bar order while
preserving each bar's anatomy, then re-runs the same rule on hundreds of
structure-free markets. Block-bootstrap mode preserves vol clustering.
- deflated_sharpe.py — Bailey & Lopez de Prado's PSR/DSR, charging for every
parameter variant tried and for skew and fat tails.
- pbo.py — probability of back…