Skip to content
Skillpedia
Machine learning41k · #4938

backtesting-frameworks

Helps your agent test investment strategies on past data. It avoids common mistakes to validate if a strategy is good.

What it does

This tool helps build testing systems for investment strategies. It ensures tests are fair by avoiding common mistakes that can make a strategy seem better than it is.

When to use it

  • ✓When creating tests for your investment ideas.
  • ✓When building the infrastructure to test strategies.
  • ✓When verifying if an investment strategy performs well.

Example of what to ask your AI

“I want to test my stock trading strategy, ensuring the tests are reliable.”

Want more? Open the sections below.

How to use

The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.

Skill link

https://github.com/wshobson/agents/blob/main/plugins/quantitative-trading/skills/backtesting-frameworks/SKILL.md

Ready-to-paste message

Use this skill to help me: https://github.com/wshobson/agents/blob/main/plugins/quantitative-trading/skills/backtesting-frameworks/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
How it works

It uses historical data intelligently, splitting it into parts for training and testing. This prevents the strategy from 'seeing the future' or the tests from being misleading due to incomplete data.

Installation

Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.

In the terminal (Claude Code, Codex, Cursor), in your project folder:

npx skills add wshobson/agents --skill backtesting-frameworks

Or download just the file:

curl -L https://raw.githubusercontent.com/wshobson/agents/main/plugins/quantitative-trading/skills/backtesting-frameworks/SKILL.md -o SKILL.md
Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

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

Bias Description Mitigation
Look-ahead Using future information Point-in-time data
Survivorship Only testing on survivors Use delisted securities
Overfitting Curve-fitting to history Out-of-sample testing
Selection Cherry-picking strategies Pre-registration
Transaction Ignoring trading costs Realistic 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
FAQ

What is 'look-ahead bias'?

It's when a test uses information that would only be available after the fact, making the strategy seem more profitable than it would be in real life.

What is 'survivorship bias'?

It's when tests only consider investments that 'survived' (didn't fail or get delisted), ignoring those that failed and skewing the results.

What are 'transaction costs'?

These are the real costs of buying and selling assets, like fees and taxes, which need to be included in tests for a realistic outcome.

Details

Original description by the author

Build robust backtesting systems for trading strategies with proper handling of look-ahead bias, survivorship bias, and transaction costs. Use when developing trading algorithms, validating strategies, or building backtesting infrastructure.

repo: wshobson/agents

Popularity

GitHub stars
41k
Ranking position
#4938
License
MIT
Updated
10/15/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills