Goal
Provide a first-class backtest module to turn indicators/signals into decisioning results with standardized portfolio metrics.
Why
The library already has strong indicator + streaming + compatibility foundations. A built-in backtest path is the biggest adoption multiplier for strategy evaluation.
Implementation prompt
Implement backtest/ primitives that run deterministic historical simulations over OHLCV bars:
- Inputs: candles/returns + signals or strategy callback
- Position model: flat/long/short with configurable fees/slippage
- Execution model: close-to-close and next-bar execution options
- Output: equity curve, trades, and metrics object
Implement metric helpers:
- Sharpe
- Sortino
- Max Drawdown
- Profit Factor
- Win Rate
- Expectancy
Scope
- New public exports under root and
ta-crypto/backtest
- Typed contracts for trades, equity curve, and summary metrics
- Deterministic results for same inputs/config
- Clear warmup handling and NA-safe calculations
Acceptance criteria
runBacktest(...) produces reproducible trade list + equity curve
- Metric package returns stable values for known fixtures
- README includes one end-to-end example from signal -> report
- Unit tests cover fees/slippage, no-trade paths, and drawdown edge cases
Test plan
- Golden fixture for one known strategy path
- Regression tests for metrics with hand-checked expected values
- Cross-check one scenario against an external reference notebook/script
Goal
Provide a first-class backtest module to turn indicators/signals into decisioning results with standardized portfolio metrics.
Why
The library already has strong indicator + streaming + compatibility foundations. A built-in backtest path is the biggest adoption multiplier for strategy evaluation.
Implementation prompt
Implement
backtest/primitives that run deterministic historical simulations over OHLCV bars:Implement metric helpers:
Scope
ta-crypto/backtestAcceptance criteria
runBacktest(...)produces reproducible trade list + equity curveTest plan