Backtester (trading-backtest)
Test the idea on history before risking money. Honest defaults: costs on, no look-ahead, caveats printed.
python3 scripts/backtest.py --spec assets/strategies/rsi2-pullback.json --universe AAPL,MSFT,NVDA,AMZN,GOOGL \
--oos-start 2021-01-01 --report rsi2.html
python3 scripts/backtest.py SPY --entry "cross_above(sma(50), sma(200))" --exit "cross_below(sma(50), sma(200))" \
--stop none --start 2005-01-01 --report golden_cross.html
python3 scripts/backtest.py --spec my.json --universe list.txt --set n=20 --set mult=3
python3 scripts/backtest.py --spec my.json --csv-dir ./data --universe A,B,C --trades-csv trades.csv --json
Example strategies: assets/strategies/*.json (RSI-2 pullback, Donchian breakout, golden cross,
VCP-style breakout, Bollinger mean reversion, Supertrend trend-follow).
Workflow
- Write the idea as rules - see strategy-spec.md and the rule language
in
../trading-scanner/references/rule-language.md. Validate rules withscreen.py --check. - Use 10+ years (
--period 10ydefault, or--start) and several symbols, not one hand-picked chart. - Always set
--oos-start(e.g. the last 30% of the period) and compare in- vs out-of-sample. - Generate
--reportand send the HTML to the user. - Feed the trade R-multiples to trading-odds to see realistic drawdown ranges.
- Try 2-3 nearby parameter values with
--set. If results collapse when a parameter moves slightly, the edge is not robust - say so.
Presenting results
Lead with: return vs benchmark, max drawdown vs benchmark, number of trades, avg R, and the out-of-sample verdict. Always include the printed caveats. Never describe backtest returns as expected future returns, and never recommend live trading on fewer than ~100 trades of evidence.