Skip to content

Phase 2: Backtesting engine#2

Merged
Jdaniel98 merged 1 commit into
mainfrom
phase-2/backtesting-engine
Mar 10, 2026
Merged

Phase 2: Backtesting engine#2
Jdaniel98 merged 1 commit into
mainfrom
phase-2/backtesting-engine

Conversation

@Jdaniel98

Copy link
Copy Markdown
Owner

Summary

  • Strategy interface with Signal enum, Trade struct, and abstract Strategy base class
  • BacktestEngine with configurable capital, commission, slippage, and risk-per-trade
  • Performance metrics: Sharpe, Sortino, Calmar ratios, max drawdown, trade statistics
  • MeanReversionStrategy: z-score based entry/exit using configurable lookback period

Test plan

  • 17/17 tests pass locally (14 existing + 3 new)
  • CI passes on Ubuntu and macOS

Add the core backtesting framework:

- Strategy interface: Signal enum (BUY/SELL/HOLD), Trade struct, abstract Strategy base class
- BacktestEngine: configurable initial capital, commission, slippage, risk-per-trade;
  runs any Strategy against PriceHistory, computes equity curve and all metrics
- Performance metrics: Sharpe ratio, Sortino ratio, Calmar ratio, max drawdown,
  trade statistics (win rate, profit factor, avg win/loss, hold duration)
- MeanReversionStrategy: z-score based entry/exit with configurable lookback,
  entry threshold, and exit threshold

17/17 tests pass (14 existing + 3 new: test_performance, test_backtest_engine,
test_mean_reversion_strategy).
@Jdaniel98 Jdaniel98 merged commit fb0539e into main Mar 10, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant