Get the FREE Ultimate OpenClaw Setup Guide →

strategy-compare

npx machina-cli add skill marketcalls/vectorbt-backtesting-skills/strategy-compare --openclaw
Files (1)
SKILL.md
2.0 KB

Create a strategy comparison script.

Arguments

Parse $ARGUMENTS as: symbol followed by strategy names

  • $0 = symbol (e.g., SBIN, RELIANCE, NIFTY)
  • Remaining args = strategies to compare (e.g., ema-crossover rsi donchian)

If only a symbol is given with no strategies, compare: ema-crossover, rsi, donchian, supertrend. If "long-vs-short" is one of the strategies, compare longonly vs shortonly vs both for the first real strategy.

Instructions

  1. Read the vectorbt-expert skill rules for reference patterns
  2. Create backtesting/strategy_comparison/ directory if it doesn't exist (on-demand)
  3. Create a .py file in backtesting/strategy_comparison/ named {symbol}_strategy_comparison.py
  4. The script must:
    • Fetch data once via OpenAlgo
    • Use TA-Lib for ALL indicators (never VectorBT built-in)
    • Use OpenAlgo ta for specialty indicators (Supertrend, Donchian, etc.)
    • Clean signals with ta.exrem() (always .fillna(False) before exrem)
    • Run each strategy on the same data
    • Indian delivery fees: fees=0.00111, fixed_fees=20 for delivery equity
    • Collect key metrics from each into a side-by-side DataFrame
    • Include NIFTY benchmark in the comparison table (via OpenAlgo NSE_INDEX)
    • Print Strategy vs Benchmark comparison table: Total Return, Sharpe, Sortino, Max DD, Win Rate, Trades, Profit Factor
    • Explain results in plain language - which strategy performed best and why
    • Plot overlaid equity curves for all strategies using Plotly (template="plotly_dark")
    • Save comparison to CSV
  5. Never use icons/emojis in code or logger output

Example Usage

/strategy-compare RELIANCE ema-crossover rsi donchian /strategy-compare SBIN long-vs-short ema-crossover

Source

git clone https://github.com/marketcalls/vectorbt-backtesting-skills/blob/master/.claude/skills/strategy-compare/SKILL.mdView on GitHub

Overview

strategy-compare creates a side-by-side stats table to evaluate multiple strategies or directions (long, short, or both) on the same symbol. It runs each strategy on identical data, includes a NIFTY benchmark, and outputs actionable insights for selecting the best approach.

How This Skill Works

The tool fetches data once via OpenAlgo and applies each strategy on the same data. It uses TA-Lib for all indicators (no VectorBT built-ins) and OpenAlgo ta for specialties like Supertrend and Donchian, then cleans signals with ta.exrem after filling NaNs. Results are aggregated into a side-by-side DataFrame, overlaid equity curves are plotted with Plotly (template plotly_dark), and a CSV export accompanies the on-screen summary.

When to Use It

  • When you need a fair, side-by-side comparison of several strategies on the same symbol
  • When choosing between long-only, short-only, or both directions for a strategy
  • When you want to benchmark performance against the NIFTY index (NSE_INDEX)
  • When you require a visual, overlaid equity curve for all strategies
  • When preparing a report for stakeholders with clear, actionable results

Quick Start

  1. Step 1: Create backtesting/strategy_comparison/ directory if it doesn't exist
  2. Step 2: Create a Python file named {symbol}_strategy_comparison.py inside backtesting/strategy_comparison/
  3. Step 3: Run the script with a symbol and one or more strategies, e.g., /strategy-compare RELIANCE ema-crossover rsi donchian

Best Practices

  • Run all strategies on identical data and timestamps to ensure fair comparison
  • Use TA-Lib indicators exclusively and apply OpenAlgo ta for specialty indicators
  • Apply consistent transaction costs: fees=0.00111, fixed_fees=20
  • Include the NIFTY benchmark (NSE_INDEX) in the comparison
  • Save results to CSV and provide a plain-language interpretation of outcomes

Example Use Cases

  • Compare ema-crossover, rsi, and donchian on RELIANCE to select a top performer
  • Assess long-vs-short against a baseline ema-crossover for SBIN
  • Evaluate strategies on NIFTY with multiple signals and a benchmark
  • Generate and review an overlaid equity plot of all strategies
  • Export a side-by-side metrics table for management review

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers