vectorbt-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 f

By marketcalls · 2,655 installs

npx skills add marketcalls/vectorbt-backtesting-skills --skill vectorbt-expert

Source repository · Upstream listing

VectorBT Backtesting Expert Skill Environment Python with vectorbt, pandas, numpy, plotly Data sources: OpenAlgo (Indian markets), DuckDB (direct database), yfinance (US/Global), CCXT (Crypto), custom providers DuckDB support: supports both custom DuckDB and OpenAlgo Historify format API keys loaded from single root .env via python dotenv + find dotenv() — never hardcode keys Technical indicators: OpenAlgo ta (DEFAULT from openalgo import ta , 100+ indicators covering trend/momentum/volatility/volume/oscillators/statistical/hybrid). Use TA Lib only if the user explicitly asks for TA Lib/talib. NEVER use VectorBT built in indicators either way. Specialty indicators (no TA Lib equivalent, always openalgo.ta ): Supertrend, Donchian, Ichimoku, HMA, KAMA, ALMA, ZLEMA, VWMA Signal cleaning: openalgo.ta for exrem, crossover, crossunder, flip (always, regardless of indicator library) Fee model: Indian market standard (STT + statutory charges + Rs 20/order) Benchmark: NIFTY 50 via OpenAlgo ( NSE INDEX ) by default Charts: Plotly with template="plotly dark" Environment variables loaded from single .env at project root via find dotenv() (walks up from script dir) Scripts go in backtesting/{strategy name}/ directories (created on demand, not pre created) Never use icons/emojis in code or logger output Critical Rules 1. Default to OpenAlgo ta ( from openalgo import ta ) for ALL technical indicators (EMA, SMA, RSI, MACD, BBANDS, ATR, ADX, STDDEV, MOM, and 90+ more). Only use TA Lib if the user explicitly requests "talib"/"TA Lib" in their prompt. NEVER use vbt.MA.run() , vbt.RSI.run() , or any VectorBT built in indicator with either library. 2. Always use OpenAlgo ta for indicators not in TA Lib at all: Supertrend, Donchian, Ichimoku, HMA, KAMA, ALMA, ZLEMA, VWMA these have no TA Lib equivalent, so they're openalgo.ta even in a TA Lib opt in script. 3. Use OpenAlgo ta for signal utilities: ta.exrem() , ta.crossover() , ta.crossunder() , ta.flip() . If openalgo.ta is not importable (standalone DuckDB), use inline exrem() fallback. See [duckdb data](rules/duckdb data.md). 4. Always clean signals with ta.exrem() after generating raw buy/sell signals. Always .fillna(False) before exrem. 5. Market specific fees : India ([indian market costs](rules/indian market costs.md)), US ([us market costs](rules/us market costs.md)), Crypto ([crypto market costs](rules/crypto market costs.md)). Auto select based on user's market. 6. Default benchmarks : India=NIFTY via OpenAlgo, US=S&P 500 ( ^GSPC ), Crypto=Bitcoin ( BTC USD ). See [data fetching](rules/data fetching.md) Market Selection Guide. 7. Always produce a Strategy vs Benchmark comparison table after every backtest. 8. Always explain the backtest report in plain language so even normal traders understand risk and strength. 9. Plotly candlestick charts must use xaxis type="category" to avoid weekend gaps. 10. Whole shares : Always set min size=1, size granularity=1 for equities. 11. DuckDB data loading : When user provides a DuckDB path, load data directly using duckdb.connect() with read only=True . Auto detect format: OpenAlgo Historify (table market data , epoch timestamps) vs custom (table ohlcv , date+time columns). See [duckdb data](rules/duckdb data.md). Modular Rule Files Detailed reference for each topic is in rules/ : Rule File Topic [data fetching](rules/data fetching.md) OpenAlgo (India), yfinance (US), CCXT (Crypto), custom providers, .env setup [simulation modes](rules/simulation modes.md) from signals, from orders, from holding, direction types [position sizing](rules/position sizing.md) Amount/Value/Percent/TargetPercent sizing [indicators signals](rules/indicators signals.md) OpenAlgo ta indicator reference (default), TA Lib opt in, signal generation [openalgo ta helpers](rules/openalgo ta helpers.md) Complete OpenAlgo ta catalog (100+ indicators): exrem, crossover, Supertrend, Donchian, Ichimoku, MAs [stop loss take profit](rules/stop loss take profit.md) Fixed SL, TP, trailing stop [parameter optimization](rules/parameter optimization.md) Broadcasting and loop based optimization [performance analysis](rules/performance analysis.md) Stats, metrics, benchmark comparison, CAGR [plotting](rules/plotting.md) Candlestick (category x axis), VectorBT plots, custom Plotly [indian market costs](rules/indian market costs.md) Indian market fee model by segment [us market costs](rules/us market costs.md) US market fee model (stocks, options, futures) [crypto market costs](rules/crypto market costs.md) Crypto fee model (spot, USDT M, COIN M futures) [futures backtesting](rules/futures backtesting.md) Lot sizes (SEBI revised Dec 2025), value sizing [long short trading](rules/long short trading.md) Simultaneous long/short, direction comparison [duckdb data](rules/duckdb data.md) DuckDB direct loading, Historify format, auto detect, resampling, multi symbol [csv data resampling](rules/csv data resampling.md) Loading CSV, resampling with Indian market alignment [walk forward](rules/walk forward.md) Walk forward analysis, WFE ratio [robustness testing](rules/robustness testing.md) Monte Carlo, noise test, parameter sensitivity, delay test [pitfalls](rules/pitfalls.md) Common mistakes and checklist before going live [strategy catalog](rules/strategy catalog.md) Strategy reference with code snippets [openstatz tearsheet](rules/openstatz tearsheet.md) OpenStatz interactive offline dashboard, metrics, Monte Carlo (replaces QuantStats) Strategy Templates (in rules/assets/) Production ready scripts with realistic fees, NIFTY benchmark, comparison table, and plain language report: Template Path Description EMA Crossover assets/ema crossover/backtest.py EMA 10/20 crossover RSI assets/rsi/backtest.py RSI(14) oversold/overbought Donchian assets/donchian/backtest.py Donchian channel breakout Supertrend assets/supertrend/backtest.py Supertrend with intraday sessions MACD assets/macd/backtest.py MACD signal candle breakout SDA2 assets/sda2/backtest.py SDA2 trend following Momentum assets/momentum/backtest.py Double momentum (MOM + MOM of MOM) Dual Momentum assets/dual momentum/backtest.py Quarterly ETF rotation Buy & Hold assets/buy hold/backtest.py Static multi asset allocation RSI Accumulation assets/rsi accumulation/backtest.py Weekly RSI slab wise accumulation Walk Forward assets/walk forward/template.py Walk forward analysis template Realistic Costs assets/realistic costs/template.py Transaction cost impact comparison Quick Template: Standard Backtest Script Quick Template: DuckDB Backtest Script If the user explicitly asks for TA Lib, skip the try/except above and import talib as tl directly instead the exrem fallback is only for when openalgo itself is unavailable.