Optimize strategy parameters using VectorBT. Tests parameter combinations and generates heatmaps.
This skill generates parameter-optimization scripts for trading strategies using VectorBT. It solves the problem of finding good strategy parameters by systematically testing many parameter combinations, collecting performance metrics for each, and visualizing the results as heatmaps so a trader can see how returns and risk vary across the grid. It is oriented toward Indian equity and futures markets and integrates with the OpenAlgo platform for data and indicators.
Given a strategy, symbol, exchange, and interval (defaulting to ema-crossover, SBIN, NSE, daily), it creates a Python script under a per-strategy backtesting directory. The script loads environment variables from a project .env via find_dotenv and fetches historical data through OpenAlgo's client.history(), or reads directly from a DuckDB file in read-only mode when a path is provided. It uses OpenAlgo's ta module for all indicators by default (switching to TA-Lib only on explicit request), cleans signals with ta.exrem(), runs loop-based optimization with tqdm progress bars over defined parameter ranges, and tracks total return, Sharpe ratio, max drawdown, and trade count per combination. It applies Indian delivery fees, finds best parameters by both total return and Sharpe, prints top-10 tables, generates dark-themed Plotly heatmaps, fetches a NIFTY benchmark for comparison, prints a strategy-versus-benchmark table, explains results in plain language, and saves output to CSV. It also encodes lot-size-aware sizing for NIFTY and BANKNIFTY futures.
It targets quantitative and retail traders and strategy developers backtesting on Indian markets. It reads credentials from a local .env for the OpenAlgo API, which is a standard configuration pattern; DuckDB access is explicitly read-only, and there is no data exfiltration or destructive behavior.
A Python parameter-optimization script for a chosen VectorBT strategy that tests parameter combinations, tracks total return, Sharpe ratio, max drawdown and trade count, generates Plotly heatmaps, compares against a NIFTY benchmark, and saves results to CSV.
Strategy, symbol, exchange, and interval, for example /optimize ema-crossover RELIANCE NSE D. Defaults are ema-crossover, SBIN, NSE, and daily (D). If no arguments are given it asks which strategy to optimize.
It expects a project .env (loaded via find_dotenv) with OpenAlgo credentials for client.history(), or a DuckDB file path for direct read-only access. It relies on VectorBT, OpenAlgo's ta module, tqdm, and Plotly; TA-Lib is used only if explicitly requested.
Yes. It applies Indian delivery fees (fees=0.00111, fixed_fees=20) and uses lot-size-aware sizing for futures, such as min_size and size_granularity of 65 for NIFTY and 30 for BANKNIFTY.
It reads API credentials from a local .env file, a standard configuration approach, and opens any DuckDB data source in read-only mode. It does not transmit credentials elsewhere or perform destructive operations.
Quick Setup:
.claude/skills/Repository
marketcalls/vectorbt-backtesting-skills