con un clic
optimize
// Optimize strategy parameters using VectorBT. Tests parameter combinations and generates heatmaps.
// Optimize strategy parameters using VectorBT. Tests parameter combinations and generates heatmaps.
Quick backtest a strategy on a symbol. Creates a complete .py script with data fetch, signals, backtest, stats, and plots.
Quickly fetch data and print key backtest stats for a symbol with a default EMA crossover strategy. No file creation needed - runs inline in a notebook cell or prints to console.
Set up the Python backtesting environment. Detects OS, creates virtual environment, installs dependencies (openalgo, ta-lib, vectorbt, plotly), and creates the backtesting folder structure.
Compare multiple strategies or directions (long vs short vs both) on the same symbol. Generates side-by-side stats table.
VectorBT backtesting expert. Use when user asks to backtest strategies, create entry/exit signals, analyze portfolio performance, optimize parameters, fetch historical data, use VectorBT/vectorbt, compare strategies, position sizing, equity curves, drawdown charts, or trade analysis. Also triggers for openalgo.ta helpers (exrem, crossover, crossunder, flip, donchian, supertrend).
| name | optimize |
| description | Optimize strategy parameters using VectorBT. Tests parameter combinations and generates heatmaps. |
| argument-hint | [strategy] [symbol] [exchange] [interval] |
| allowed-tools | Read, Write, Edit, Bash, Glob, Grep |
Create a parameter optimization script for a VectorBT strategy.
Parse $ARGUMENTS as: strategy symbol exchange interval
$0 = strategy name (e.g., ema-crossover, rsi, donchian). Default: ema-crossover$1 = symbol (e.g., SBIN, RELIANCE, NIFTY). Default: SBIN$2 = exchange (e.g., NSE, NFO). Default: NSE$3 = interval (e.g., D, 1h, 5m). Default: DIf no arguments, ask the user which strategy to optimize.
backtesting/{strategy_name}/ directory if it doesn't exist (on-demand).py file in backtesting/{strategy_name}/ named {symbol}_{strategy}_optimize.py.env from project root using find_dotenv() and fetch data via OpenAlgo client.history()duckdb.connect(path, read_only=True). See vectorbt-expert rules/duckdb-data.md.openalgo.ta is not importable (standalone DuckDB), use inline exrem() fallback.ta.exrem() to clean signals (always .fillna(False) before exrem)tqdm for progress barsfees=0.00111, fixed_fees=20 for delivery equitytemplate="plotly_dark")min_size=65, size_granularity=65min_size=30, size_granularity=30| Strategy | Parameter 1 | Parameter 2 |
|---|---|---|
| ema-crossover | fast EMA: 5-50 | slow EMA: 10-60 |
| rsi | window: 5-30 | oversold: 20-40 |
| donchian | period: 5-50 | - |
| supertrend | period: 5-30 | multiplier: 1.0-5.0 |
/optimize ema-crossover RELIANCE NSE D
/optimize rsi SBIN