backtest_strategy
Run institutional-grade backtests on historical data for any stock, crypto, ETF, or index. Choose from RSI, Bollinger, MACD, EMA cross, Supertrend, or Donchian strategies and get win rate, Sharpe ratio, drawdown, and more.
Instructions
Backtest a trading strategy on historical data with institutional-grade metrics.
Args: symbol: Yahoo Finance symbol — stocks (AAPL, TSLA, NVDA), crypto (BTC-USD, ETH-USD), ETFs (SPY, QQQ), indices (^GSPC, ^IXIC), Turkish (THYAO.IS) strategy: Trading strategy to test: 'rsi' — Buy oversold (RSI<30), Sell overbought (RSI>70) 'bollinger' — Buy at lower Bollinger Band, Sell at middle band 'macd' — Buy on MACD golden cross, Sell on death cross 'ema_cross' — Buy EMA20>EMA50 crossover, Sell on reversal 'supertrend' — Buy on bullish Supertrend flip 'donchian' — Buy Donchian Channel breakout (Turtle Trader style) period: Historical data period: '1mo', '3mo', '6mo', '1y', '2y' initial_capital: Starting capital in USD (default: $10,000) commission_pct: Per-trade commission % (default: 0.1%) slippage_pct: Per-trade slippage % (default: 0.05%) interval: Timeframe: '1d' (daily, default) or '1h' (hourly) include_trade_log: Include full per-trade log with entry/exit/P&L detail (default: False) include_equity_curve: Include equity curve data points for charting (default: False)
Returns: Institutional-grade backtest report: win rate, total return, Sharpe ratio, Calmar ratio, max drawdown, profit factor, expectancy, best/worst trade, vs buy-and-hold benchmark. Optionally includes full trade log and equity curve.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| period | No | 1y | |
| symbol | Yes | ||
| interval | No | 1d | |
| strategy | Yes | ||
| slippage_pct | No | ||
| commission_pct | No | ||
| initial_capital | No | ||
| include_trade_log | No | ||
| include_equity_curve | No |