| name | backtesting-trading-strategies |
| description | 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".
|
| allowed-tools | Read, Write, Edit, Grep, Glob, Bash(python:*) |
| version | 1.28.0 |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| license | MIT |
| tags | ["crypto","testing","performance"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Backtesting Trading Strategies
Overview
Validate trading strategies against historical data before risking real capital. This skill provides a complete backtesting framework with 8 built-in strategies, comprehensive performance metrics, and parameter optimization.
Key Features:
- 8 pre-built trading strategies (SMA, EMA, RSI, MACD, Bollinger, Breakout, Mean Reversion, Momentum)
- Full performance metrics (Sharpe, Sortino, Calmar, VaR, max drawdown)
- Parameter grid search optimization
- Equity curve visualization
- Trade-by-trade analysis
Prerequisites
Install required dependencies:
set -euo pipefail
pip install pandas numpy yfinance matplotlib
Optional for advanced features:
set -euo pipefail
pip install ta-lib scipy scikit-learn
Instructions
-
Fetch historical data (cached to ${CLAUDE_SKILL_DIR}/data/ for reuse):
python ${CLAUDE_SKILL_DIR}/scripts/fetch_data.py --symbol BTC-USD --period 2y --interval 1d
-
Run a backtest with default or custom parameters:
python ${CLAUDE_SKILL_DIR}/scripts/backtest.py --strategy sma_crossover --symbol BTC-USD --period 1y
python ${CLAUDE_SKILL_DIR}/scripts/backtest.py \
--strategy rsi_reversal \
--symbol ETH-USD \
--period 1y \
--capital 10000 \
--params '{"period": 14, "overbought": 70, "oversold": 30}'
-
Analyze results saved to ${CLAUDE_SKILL_DIR}/reports/ -- includes *_summary.txt (performance metrics), *_trades.csv (trade log), *_equity.csv (equity curve data), and *_chart.png (visual equity curve).
-
Optimize parameters via grid search to find the best combination:
python ${CLAUDE_SKILL_DIR}/scripts/optimize.py \
--strategy sma_crossover \
--symbol BTC-USD \
--period 1y \
--param-grid '{"fast_period": [10, 20, 30], "slow_period": [50, 100, 200]}'