Strategy backtesting with SMA crossover and RSI mean-reversion against historical crypto data
Test trading strategies against historical OHLCV data to evaluate performance before risking real capital.
A trend-following strategy based on moving average crossovers.
| Parameter | Default | Description |
|---|---|---|
| Fast Period | 10 | Fast SMA lookback |
| Slow Period | 30 | Slow SMA lookback |
| Minimum Bars | 500 | Minimum OHLCV bars needed |
See references/strategies.md for full pseudocode.
A mean-reversion strategy that buys oversold conditions and sells overbought conditions.
| Parameter | Default | Description |
|---|---|---|
| RSI Period | 14 | RSI calculation lookback |
| Oversold Level | 30 | Entry trigger level |
| Overbought Level | 70 | Exit trigger level |
See references/strategies.md for full pseudocode.
Starting equity: $10,000
equity = 10000
For each completed trade:
equity = equity * (1 + trade_pnl_pct / 100)
Total Return % = ((final_equity - 10000) / 10000) * 100
This models fully invested equity (each trade uses 100% of current equity).
Every backtest produces these metrics:
| Metric | Formula |
|---|---|
| Total Return % | ((Final Equity - 10000) / 10000) * 100 |
| Sharpe Ratio | Annualized mean return / annualized std dev (365-day) |
| Max Drawdown % | Maximum peak-to-trough decline in equity series |
| Win Rate % | Winning trades / total trades * 100 |
| Profit Factor | Gross profit / gross loss |
| Total Trades | Count of completed round-trip trades |
Plus the full trade list with entry/exit prices, times, and PnL for each trade.
| Parameter | Description |
|---|---|
| investmentPerTrade | Fixed USD amount per buy |
| frequency | Interval between buys (e.g., "daily", "weekly", "monthly") |
DCA buys a fixed dollar amount at regular intervals regardless of price. Effective for reducing impact of volatility on average entry price.
| Parameter | Description |
|---|---|
| bottomPrice | Lower bound of the grid |
| topPrice | Upper bound of the grid |
| gridLevels | Number of grid lines between bottom and top |
| investmentAmount | Total capital allocated to the grid |
Grid spacing: (topPrice - bottomPrice) / gridLevels
Each grid level has a buy order (when price drops to that level) and a sell order (at the next level up). Investment per level = investmentAmount / gridLevels.