backtest_strategy
Test a Simple Moving Average crossover strategy by simulating trades based on SMA crossovers, comparing results against buy-and-hold performance for informed investment decisions.
Instructions
Backtest a Simple Moving Average (SMA) crossover strategy. [PRO]
Tests: Buy when short SMA crosses above long SMA, sell when it crosses below. Compares strategy return vs buy-and-hold.
Args: symbol: Stock ticker (e.g., RELIANCE, AAPL, TCS) short_window: Short SMA period in days (default: 20) long_window: Long SMA period in days (default: 50) period: Backtest period: 1y, 2y, 5y (default: 2y) initial_capital: Starting capital (default: 100000)
Examples: backtest_strategy("RELIANCE") → Default 20/50 SMA backtest backtest_strategy("AAPL", 10, 30, "5y") → Custom 10/30 SMA, 5 years backtest_strategy("TCS", 50, 200, "5y", 500000) → Golden cross, 5L capital
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | ||
| short_window | No | ||
| long_window | No | ||
| period | No | 2y | |
| initial_capital | No |