New to Claude Skills? Learn how to install them →

wshobson on GitHub

Backtesting Frameworks

Free

Create reliable backtesting systems for trading strategies.

Get this skill

Free · Opens the source repo

What Backtesting Frameworks does

Backtesting Frameworks provides a structured approach to building robust backtesting systems for trading strategies. It focuses on addressing common pitfalls such as look-ahead bias, survivorship bias, and transaction costs, which can significantly skew the performance estimates of trading algorithms. By implementing best practices and proper backtest structure, users can validate their strategies more effectively and ensure that their results are reliable and applicable in real-world scenarios.

The skill emphasizes the importance of a systematic methodology for backtesting. It outlines a clear structure that includes the use of historical data divided into training, validation, and test sets. This separation helps in developing and optimizing strategies without peeking at future data, thereby reducing the risk of overfitting. Additionally, the skill introduces walk-forward analysis, which allows for continuous evaluation of the strategy's performance over time, ensuring that it remains effective in changing market conditions.

Users of this skill range from quantitative analysts to algorithmic traders who need to validate their trading strategies rigorously. By following the guidelines provided, they can build backtesting systems that not only comply with industry standards but also provide insights into the potential performance of their strategies under various market conditions. The detailed examples and implementation patterns included in the references further enhance the learning experience and facilitate effective application.

In summary, Backtesting Frameworks serves as a comprehensive guide for anyone involved in trading strategy development, offering the tools and knowledge necessary to create reliable backtesting systems that can withstand the complexities of financial markets.

When to use it

Use this skill when developing or validating trading algorithms to ensure robust backtesting practices.

When not to use it

This skill may not be suitable for users looking for a simple backtesting tool without the need for in-depth analysis or structure.

What you can build with it

Developing a New Trading Strategy

When creating a new trading strategy, use this skill to ensure your backtests are free from common biases that could mislead performance evaluations.

Validating Existing Strategies

If you have existing trading strategies, apply this skill to validate their performance under realistic conditions, including transaction costs and market impact.

Building Backtesting Infrastructure

Use this skill when setting up a backtesting infrastructure that requires a structured approach to avoid pitfalls and enhance reliability.

How to install Backtesting Frameworks

View source

1. Install with the skills CLI

npx skills add wshobson/agents/backtesting-frameworks --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by wshobson

Backtesting Frameworks

Build robust, production-grade backtesting systems that avoid common pitfalls and produce reliable strategy performance estimates.

When to Use This Skill

  • Developing trading strategy backtests
  • Building backtesting infrastructure
  • Validating strategy performance
  • Avoiding common backtesting biases
  • Implementing walk-forward analysis
  • Comparing strategy alternatives

Core Concepts

1. Backtesting Biases

BiasDescriptionMitigation
Look-aheadUsing future informationPoint-in-time data
SurvivorshipOnly testing on survivorsUse delisted securities
OverfittingCurve-fitting to historyOut-of-sample testing
SelectionCherry-picking strategiesPre-registration
TransactionIgnoring trading costsRealistic cost models

2. Proper Backtest Structure

Historical Data
      │
      ▼
┌─────────────────────────────────────────┐
│              Training Set               │
│  (Strategy Development & Optimization)  │
└─────────────────────────────────────────┘
      │
      ▼
┌─────────────────────────────────────────┐
│             Validation Set              │
│  (Parameter Selection, No Peeking)      │
└─────────────────────────────────────────┘
      │
      ▼
┌─────────────────────────────────────────┐
│               Test Set                  │
│  (Final Performance Evaluation)         │
└─────────────────────────────────────────┘

3. Walk-Forward Analysis

Window 1: [Train──────][Test]
Window 2:     [Train──────][Test]
Window 3:         [Train──────][Test]
Window 4:             [Train──────][Test]
                                     ─────▶ Time

Detailed worked examples and patterns

Detailed sections (starting with ## Implementation Patterns) live in references/details.md. Read that file when the navigation summary above is insufficient.

Best Practices

Do's

  • Use point-in-time data - Avoid look-ahead bias
  • Include transaction costs - Realistic estimates
  • Test out-of-sample - Always reserve data
  • Use walk-forward - Not just train/test
  • Monte Carlo analysis - Understand uncertainty

Don'ts

  • Don't overfit - Limit parameters
  • Don't ignore survivorship - Include delisted
  • Don't use adjusted data carelessly - Understand adjustments
  • Don't optimize on full history - Reserve test set
  • Don't ignore capacity - Market impact matters

Frequently asked questions about Backtesting Frameworks

Similar skills