Skip to content

Latest commit

 

History

History
65 lines (48 loc) · 2.7 KB

File metadata and controls

65 lines (48 loc) · 2.7 KB

Backtesting, execution, and performance module

Goal

Simulate only information and orders that would have been available at the time, charge realistic costs once, and compare the strategy with fair benchmarks and falsification controls.

How it works

  • walk_forward.py creates chronological training and test windows.
  • engine.py generates decisions without training on future labels.
  • broker.py and execution.py fill at the next available open.
  • costs.py and the threshold execution path charge fixed fees and one-way spread/slippage.
  • Positions drift between rebalances; optional small trades may be skipped, but obsolete positions are always closed.
  • metrics.py calculates cumulative return, CAGR, Sharpe, volatility, drawdown, VaR, and CVaR.
  • Experiment modules add block-bootstrap intervals and shuffled-score distributions.

Correctness improvements already made

  • Replaced close-to-close evaluation with next-open execution-aligned returns.
  • Corrected fill dates so transactions appear on the actual fill session.
  • Removed double counting of spread and slippage.
  • Corrected astronomical CAGR, volatility, return, and fee outputs caused by accounting defects.
  • Added identical execution treatment for model, control, and benchmark portfolios.
  • Added fail-closed confirmation paths and artifact hashes.

Latest validated execution result

For the 64-week v4 public confirmation:

  • Average weekly turnover: 5.43%.
  • Average executed orders: 3.08 per week.
  • Annualized variable cost: 0.23%.
  • Annualized fixed cost: 0.15%.
  • Total modeled transaction cost: approximately 0.38% annually.
  • Model net CAGR: 11.34%; Sharpe: 1.11; maximum drawdown: -5.73%.

The primary comparison was 70% SPY plus 30% cash, including the requested hypothetical 0.5% annual benchmark fee. A fully invested SPY comparison answers a different opportunity-cost question and should not be mistaken for equal exposure.

Limitations

  • Costs are static and omit participation, price impact, partial fills, taxes, borrow, and capacity.
  • Weekly return samples are short for precise Sharpe or active-return inference.
  • A backtest cannot validate unavailable historical data or publication timing.
  • Performance metrics must never be reported without their period, exposure, and benchmark.

Main commands

python -m src.cli run-backtest --help
python -m src.cli run-ablation --help
python -m src.cli run-revealing-controls --help
python -m src.cli analyze-regime-stability --help
python -m src.cli generate-report --help

Related documentation