All skills
wshobson avatar

/backtesting-frameworks

@be57c0b
by Seth Hobsonwshobson/agents40k stars
4,281

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.

Use this Skill: https://skilld.dev/gh/wshobson/agents/backtesting-frameworks

This session only. Nothing lands on disk.

SKILL.md

β‰ˆ66 tokens always: the name and description. β‰ˆ805 when used: this file. β‰ˆ4.5k more on demand in 1 file.

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

Source: SKILL.md on GitHub

No alerts16d5 checks Β· Risk SAFE
  • Gen Agent Trust Hub16d

    The skill provides standard, clean framework templates and code implementations for financial backtesting. No security vulnerabilities or malicious patterns were detected.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW Β· No issues

  • Runlayer6mo

    1 file scanned Β· No issues

  • ZeroLeaks5mo

    2 findings Β· Score: 80/100

Signed by skilld at be57c0b. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 days ago.

Activeupdated 4 months ago
  • Python
  • backtesting
  • trading
  • strategy
  • bias
  • walk-forward
  • out-of-sample
  • transaction-costs

README badge

README badge for wshobson/agents/backtesting-frameworks

Provides patterns and best practices for building backtesting systems that account for look-ahead bias, survivorship bias, transaction costs, and overfitting. Use this skill when developing trading strategy backtests, implementing walk-forward analysis, or validating strategy performance on out-of-sample data.

Generated from the current SKILL.md.

Does this skill cover specific backtesting libraries like Backtrader or VectorBT?
No. The skill focuses on backtesting principles and biases rather than implementations in particular libraries. It teaches the concepts you need to avoid look-ahead bias, survivorship bias, and overfitting regardless of your chosen framework.
What biases does this skill address?
It covers look-ahead bias, survivorship bias, overfitting, selection bias, and transaction costs. Each has a concrete mitigation strategy documented in the skill.
Does this include walk-forward analysis?
Yes. The skill includes walk-forward analysis patterns and explains how to structure rolling windows for strategy validation.
Can I use this for crypto or forex strategies?
The principles apply universally to any asset class with historical data, though the skill does not provide asset-class-specific implementations or examples.

Generated from the current SKILL.md. These answers refresh after source changes.