optimize
Backtesting strategy parameter optimization with VectorBT, generating performance heatmaps and benchmark comparisons.
- Accepts strategy name, symbol, exchange, and interval; creates optimization script in
backtesting/{strategy}/directory - Loads market data from OpenAlgo via
.envconfiguration or directly from DuckDB; uses TA-Lib for all indicators with OpenAlgo ta for specialty indicators like Supertrend and Donchian - Tests parameter combinations across sensible ranges (e.g., EMA 5-50 for fast, 10-60 for slow), tracking total return, Sharpe ratio, max drawdown, and trade count per combo
- Generates Plotly heatmaps for total return and Sharpe ratio; fetches NIFTY benchmark and prints strategy vs benchmark comparison table with plain-language results explanation
- Applies Indian delivery fees (0.00111 + 20 fixed) and futures lot-size awareness (NIFTY 65, BANKNIFTY 30); saves results to CSV
Create a parameter optimization script for a VectorBT strategy.
Arguments
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: D
If no arguments, ask the user which strategy to optimize.
Instructions
More from marketcalls/vectorbt-backtesting-skills
backtest
Quick backtest a strategy on a symbol. Creates a complete .py script with data fetch, signals, backtest, stats, and plots.
1.3Kvectorbt-expert
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).
1.2Kstrategy-compare
Compare multiple strategies or directions (long vs short vs both) on the same symbol. Generates side-by-side stats table.
877quick-stats
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.
832setup
Set up the Python backtesting environment. Detects OS, creates virtual environment, installs dependencies (openalgo, ta-lib, vectorbt, plotly), and creates the backtesting folder structure.
792