跳到正文
Skillpedia
机器学习41k · #6771

backtesting-frameworks

它能做什么

这个工具可以帮你搭建投资策略的测试系统。它会避免一些常见错误,确保测试公平,不会让策略看起来比实际表现更好。

适用场景

  • ✓为你的投资想法编写测试时。
  • ✓搭建策略测试的基础设施时。
  • ✓验证某个投资策略是否真的表现良好时。

技能链接

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

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/wshobson/agents/blob/main/plugins/quantitative-trading/skills/backtesting-frameworks/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我想测试自己的股票交易策略,并确保测试结果是可靠的。”

每周 5 个新技能,1 分钟读完。

工作原理

它会智能地使用历史数据,把数据分成用于训练和用于测试的部分。这样可以避免策略“偷看未来”,也能防止因数据不完整而导致测试结果产生误导。

技术内容(原始 SKILL.md)

作者在 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
常见问题

什么是“前视偏差”(look-ahead bias)?

指测试中使用了只有事后才能获得的信息,使策略看起来比现实中更赚钱。

什么是“幸存者偏差”(survivorship bias)?

指测试只考虑了“幸存”下来的投资标的(没有失败或被退市的),忽略了那些失败的标的,从而让结果产生偏差。

什么是“交易成本”?

指买入和卖出资产时产生的实际费用,比如手续费和税费。测试中需要把这些成本计算进去,结果才会更贴近现实。

详情

作者的原始描述

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

热度

GitHub 星标
41k
排名
#6771
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能