Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Implement and analyze trading strategy backtests using Python frameworks like Backtrader, Zipline, or VectorBT.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
SKILL.md
1---2name: backtesting-frameworks3description: 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.4---56# Backtesting Frameworks78Build robust, production-grade backtesting systems that avoid common pitfalls and produce reliable strategy performance estimates.910## When to Use This Skill1112- Developing trading strategy backtests13- Building backtesting infrastructure14- Validating strategy performance15- Avoiding common backtesting biases16- Implementing walk-forward analysis17- Comparing strategy alternatives1819## Core Concepts2021### 1. Backtesting Biases2223| Bias | Description | Mitigation |24| ---------------- | ------------------------- | ----------------------- |25| **Look-ahead** | Using future information | Point-in-time data |26| **Survivorship** | Only testing on survivors | Use delisted securities |27| **Overfitting** | Curve-fitting to history | Out-of-sample testing |28| **Selection** | Cherry-picking strategies | Pre-registration |29| **Transaction** | Ignoring trading costs | Realistic cost models |3031### 2. Proper Backtest Structure3233```34Historical Data35│36▼37┌─────────────────────────────────────────┐38│ Training Set │39│ (Strategy Development & Optimization) │40└─────────────────────────────────────────┘41│42▼43┌─────────────────────────────────────────┐44│ Validation Set │45│ (Parameter Selection, No Peeking) │46└─────────────────────────────────────────┘47│48▼49┌─────────────────────────────────────────┐50│ Test Set │51│ (Final Performance Evaluation) │52└─────────────────────────────────────────┘53```5455### 3. Walk-Forward Analysis5657```58Window 1: [Train──────][Test]59Window 2: [Train──────][Test]60Window 3: [Train──────][Test]61Window 4: [Train──────][Test]62─────▶ Time63```6465## Detailed worked examples and patterns6667Detailed sections (starting with `## Implementation Patterns`) live in `references/details.md`. Read that file when the navigation summary above is insufficient.6869## Best Practices7071### Do's7273- **Use point-in-time data** - Avoid look-ahead bias74- **Include transaction costs** - Realistic estimates75- **Test out-of-sample** - Always reserve data76- **Use walk-forward** - Not just train/test77- **Monte Carlo analysis** - Understand uncertainty7879### Don'ts8081- **Don't overfit** - Limit parameters82- **Don't ignore survivorship** - Include delisted83- **Don't use adjusted data carelessly** - Understand adjustments84- **Don't optimize on full history** - Reserve test set85- **Don't ignore capacity** - Market impact matters86