backtesting-trading-strategies

Backtest trading strategies against historical data and export performance metrics.

43|8|Updated Jan 5, 2025
One-click install
npx skills add https://github.com/gracefullight/stock-checker --skill backtesting-trading-strategies
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: backtesting-trading-strategies
Source: https://github.com/gracefullight/stock-checker/tree/main/.agent/skills/backtesting-trading-strategies
Command: npx skills add https://github.com/gracefullight/stock-checker --skill backtesting-trading-strategies

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pandas, numpy, yfinance, requests, matplotlib, and includes scripts (resource) and references (resource) components.

What problem does it solve?

Backtest trading strategies against historical data to compare performance and stability before risking real capital.

Core Features & Use Cases

  • Built-in backtesting framework with multiple strategies (SMA, EMA, RSI, MACD, Bollinger, Breakout, Mean Reversion, Momentum)
  • Generates comprehensive performance metrics (Total Return, CAGR, Sharpe, Sortino, Calmar) and risk measures (Max Drawdown, VaR)
  • Exports equity curves, trade logs, and chart-ready visuals for reporting and decision making
  • Use Case: validate strategy signals across assets and timeframes, then optimize parameters to improve robustness

Quick Start

Run a backtest with a chosen strategy and symbol, for example: python scripts/backtest.py --strategy sma_crossover --symbol BTC-USD --period 1y --capital 10000 --params '{"fast_period": 20, "slow_period": 50}'

Frequently Asked Questions about backtesting-trading-strategies

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I backtest a trading strategy using historical data in Python?

To backtest a trading strategy using historical data, run the provided Python script with parameters for strategy type, symbol, period, and capital. It applies signals to historical data and outputs performance metrics along with equity curves.

What performance metrics are generated when evaluating trading strategies?

Evaluating trading strategies generates performance metrics including Total Return, CAGR, Sharpe, Sortino, and Calmar ratios. It also calculates risk measures like Maximum Drawdown and Value at Risk to assess strategy stability.

Can I optimize parameters for built-in strategies like SMA crossover and RSI?

Yes, you can optimize parameters for built-in strategies like SMA crossover, EMA, RSI, MACD, and Bollinger Bands. Passing custom JSON parameters to the script allows parameterized backtests to improve robustness across assets.

Does this backtesting framework support fetching historical data for cryptocurrencies?

Yes, the backtesting framework supports fetching historical data for cryptocurrencies. It utilizes the yfinance dependency to download historical price data for assets like BTC-USD across specified timeframes.

What is the best way to compare multiple trading strategies before risking capital?

The best way to compare multiple trading strategies is running parameterized backtests across different assets and timeframes. The framework exports equity curves and trade logs, enabling side-by-side performance and risk analysis.

Why do I need pandas and matplotlib for backtesting trading strategies?

Pandas and matplotlib are required for backtesting trading strategies to manipulate historical price data arrays and visualize equity curves. They enable exporting chart-ready visual outputs for reporting and decision making.