Skip to content

jeremylongshore/tons-of-skills-marketplace / plugins/crypto/trading-strategy-backtester/skills/backtesting-trading-strategies

backtesting-trading-strategies

Verified

Backtest crypto and traditional trading strategies against historical data. Calculates performance metrics (Sharpe, Sortino, max drawdown), generates equity curves, and optimizes strategy parameters. Use when user wants to test a trading strategy, validate signals, or compare approaches. Trigger with phrases like "backtest strategy", "test trading strategy", "historical performance", "simulate trades", "optimize parameters", or "validate signals".

FileKindSize
SKILL.mdskill md6.9 KB
commands/backtest-strategy.mdmarkdown3.2 KB
commands/compare-strategies.mdmarkdown2.6 KB
commands/optimize-parameters.mdmarkdown2.4 KB
commands/walk-forward.mdmarkdown4.0 KB
config/settings.yamlconfig1.4 KB
references/errors.mdmarkdown3.9 KB
references/examples.mdmarkdown3.9 KB
references/implementation.mdmarkdown4.6 KB
scripts/backtest.pyexecutablescript14.3 KB
scripts/fetch_data.pyexecutablescript4.8 KB
scripts/metrics.pyscript13.1 KB
scripts/optimize.pyexecutablescript7.5 KB
scripts/strategies.pyscript11.1 KB
tests/test_metrics.pyscript6.2 KB
tests/test_strategies.pyscript13.7 KB

commands/compare-strategies.md

View on GitHub
---
name: compare-strategies
description: Compare multiple strategy backtests side by side
allowed-tools: Read, Write, Edit, Bash(python:*)
---

# /compare-strategies

Run multiple strategies on the same data and compare performance side by side.

## Usage

```
/compare-strategies <symbol> [strategies...] [options]
```

## Workflow

1. Fetch data once for the symbol and period
2. Run each strategy with its default (or specified) parameters
3. Collect results into a comparison table
4. Rank by chosen metric

## Example Script

```python
import sys
from pathlib import Path

sys.path.insert(0, str(Path("${CLAUDE_SKILL_DIR}/scripts")))

from backtest import load_data, run_backtest
from fetch_data import parse_period
from datetime import datetime

# Configuration
symbol = "BTC-USD"
strategies = ["sma_crossover", "ema_crossover", "rsi_reversal", "macd",
              "bollinger_bands", "breakout", "mean_reversion", "momentum"]
end = datetime.now()
start = end - parse_period("1y")

# Load data once
data_dir = Path("${CLAUDE_SKILL_DIR}/data")
data = load_data(symbol, start, end, data_dir)
data.attrs["symbol"] = symbol

# Run all strategies
results = []
for name in strategies:
    try:
        result = run_backtest(strategy_name=name, data=data.copy())
        results.append(result)
        print(f"{name:20s}  Return: {result.total_return:+8.2f}%  "
              f"Sharpe: {result.sharpe_ratio:6.2f}  "
              f"MaxDD: {result.max_drawdown:+8.2f}%  "
              f"Trades: {result.total_trades}")
    except Exception as e:
        print(f"{name:20s}  ERROR: {e}")

# Sort by Sharpe ratio
results.sort(key=lambda r: r.sharpe_ratio, reverse=True)
print(f"\nBest strategy: {results[0].strategy} (Sharpe: {results[0].sharpe_ratio:.2f})")
```

## CLI Approach

Run individual backtests and compare the summary files:

```bash
for strategy in sma_crossover ema_crossover rsi_reversal macd bollinger_bands; do
  python ${CLAUDE_SKILL_DIR}/scripts/backtest.py \
    --strategy $strategy --symbol BTC-USD --period 1y --quiet
done
```

## What to Compare

| Metric | What It Tells You |
|--------|-------------------|
| Sharpe Ratio | Best risk-adjusted return |
| Total Return | Raw profitability |
| Max Drawdown | Worst-case pain |
| Win Rate | Consistency |
| Profit Factor | Reward-to-risk per trade |
| Total Trades | Activity level / costs |

## Tips

- Always compare on the same data range and capital
- A strategy with fewer trades but higher Sharpe may be preferable to one with high return but deep drawdowns
- Consider combining uncorrelated strategies for portfolio diversification
- Use `/optimize-parameters` on the top 2-3 strategies for fine-tuning
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 323kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 323kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 323kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall