agentleFS
JerryLiu369JerryLiu369/awesome-quant-skills/skills/backtesting-audit/vectorbt-optimize/SKILL.md

vectorbt-optimize

Skill3 starsChanged 32 days agoMITView on GitHub

Create a parameter optimization script for a VectorBT strategy. Parse $ARGUMENTS as: strategy symbol exchange interval If no arguments, ask the user which strategy to optimize. /optimize ema-crossover RELIANCE NSE D /optimize rsi SBIN

  • Reads credentials

The file

We split this skill into the rules it gives an agent

11 rules. About 0 are common, 5 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Create a parameter optimization script for a VectorBT strategy.

    line 14
  2. Distinctive:

    If no arguments, ask the user which strategy to optimize.

    line 25
  3. Distinctive:

    Read the vectorbt-expert skill rules for reference patterns

    line 29
  4. Very specific:

    Create backtesting/{strategy_name}/ directory if it doesn't exist (on-demand)

    line 30
  5. Very specific:

    Create a .py file in backtesting/{strategy_name}/ named {symbol}_{strategy}_optimize.py

    line 31
  6. Very specific:

    If user provides a DuckDB path, load data directly via duckdb.connect(path, read_only=True).

    line 34
  7. Very specific:

    If openalgo.ta is not importable (standalone DuckDB), use inline exrem() fallback.

    line 35
  8. Very specific:

    Use ta.exrem() to clean signals (always .fillna(False) before exrem)

    line 38
  9. Distinctive:

    Use loop-based optimization to collect multiple metrics per combo

    line 40
  10. Very specific:

    Use tqdm for progress bars

    line 42
  11. Distinctive:

    Never use icons/emojis in code or logger output

    line 52

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md
<!-- Imported from: https://github.com/marketcalls/vectorbt-backtesting-skills Source Path: .claude/skills/optimize/SKILL.md Curated for awesome-quant-skills -->

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.

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

  1. Read the vectorbt-expert skill rules for reference patterns
  2. Create backtesting/{strategy_name}/ directory if it doesn't exist (on-demand)
  3. Create a .py file in backtesting/{strategy_name}/ named {symbol}_{strategy}_optimize.py
  4. The script must:
    • Load .env from project root using find_dotenv() and fetch data via OpenAlgo client.history()
    • If user provides a DuckDB path, load data directly via duckdb.connect(path, read_only=True). See vectorbt-expert rules/duckdb-data.md.
    • If openalgo.ta is not importable (standalone DuckDB), use inline exrem() fallback.
    • Use OpenAlgo ta for ALL indicators by default (never VectorBT built-in). Only switch to TA-Lib if the user explicitly says "talib"/"TA-Lib"
    • Always use OpenAlgo ta for specialty indicators (Supertrend, Donchian, etc.) - no TA-Lib equivalent exists
    • Use ta.exrem() to clean signals (always .fillna(False) before exrem)
    • Define sensible parameter ranges for the chosen strategy
    • Use loop-based optimization to collect multiple metrics per combo
    • Track: total_return, sharpe_ratio, max_drawdown, trade_count for each combination
    • Use tqdm for progress bars
    • Indian delivery fees: fees=0.00111, fixed_fees=20 for delivery equity
    • Find best parameters by total return AND by Sharpe ratio
    • Print top 10 results for both criteria
    • Generate Plotly heatmap of total return across parameter grid (template="plotly_dark")
    • Generate Plotly heatmap of Sharpe ratio across parameter grid
    • Fetch NIFTY benchmark and compare best parameters vs benchmark
    • Print Strategy vs Benchmark comparison table
    • Explain results in plain language for normal traders
    • Save results to CSV
  5. Never use icons/emojis in code or logger output
  6. For futures symbols, use lot-size-aware sizing:
    • NIFTY: min_size=65, size_granularity=65
    • BANKNIFTY: min_size=30, size_granularity=30

Default Parameter Ranges

StrategyParameter 1Parameter 2
ema-crossoverfast EMA: 5-50slow EMA: 10-60
rsiwindow: 5-30oversold: 20-40
donchianperiod: 5-50-
supertrendperiod: 5-30multiplier: 1.0-5.0

Example Usage

/optimize ema-crossover RELIANCE NSE D /optimize rsi SBIN

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.