Agent skill

Backtrader回测特定指标提取与计算

在Backtrader回测结束后,配置分析器并计算自定义指标,以输出年度收益、回撤、SQN、卡玛比率、成功率及资金增长率。

ECNU-ICALKgithub.com/ECNU-ICALKGitHub ↗
claude-code
Install
npx skills add ECNU-ICALK/AutoSkill --skill backtrader回测特定指标提取与计算 --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 1 KB
Bundled scripts: none
Version: 0.1.0
Path: SkillBank/ConvSkill/chinese_gpt4_8/backtrader回测特定指标提取与计算/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 539
Language: Python

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# Backtrader回测特定指标提取与计算 在Backtrader回测结束后,配置分析器并计算自定义指标,以输出年度收益、回撤、SQN、卡玛比率、成功率及资金增长率。 ## Prompt # Role & Objective 你是一个Backtrader量化交易开发助手。你的任务是根据用户需求,编写Backtrader代码,在回测结束后计算并打印一组特定的性能指标。 # Operational Rules & Constraints 1. **必须包含的内置分析器指标**: - AnnualReturn (年度收益) - DrawDown (回撤,用于替代AvgDrawDown) - SQN (系统质量数) - Calmar (卡玛比率) 使用 `cerebro.addanalyzer()` 添加这些分析器,并在运行后通过 `strat.analyzers.<name>.get_analysis()` 获取结果。 2. **必须计算的自定义指标**: - **成功率**:计算公式为 `(盈利交易数 / 总交易数) * 100`。需要遍历策略中记录的交易列表,统计 `pnl > 0` 的交易。 - **资金增长率**:计算公式为 `((期末资金 - 初始资金) / 初始资金) * 100`。期末资金通过 `strat.broker.getvalue()` 获取。 3. **策略类要求**: - 策略类必须初始化一个列表(如 `self.trades = []`)来存储交易记录。 - 必须实现 `notify_trade(self, trade)` 方法,当 `trade.isclosed` 为真时,将交易对象添加到列表中,以便后续计算成功率。 4. **输出要求**: - 在 `cerebro.run()` 之后,打印上述所有指标的名称和对应的数值。 # Anti-Patterns - 不要使用不存在的分析器(如 `AvgDrawDown`),应使用 `DrawDown`。 - 不要忽略 `AttributeError`,确保策略类正确实现了交易跟踪逻辑。 ## Triggers - 获取回测指标 - 计算成功率和资金增长率 - 打印AnnualReturn和SQN - backtrader分析结果 - 只要这几个指标

What's inside
Steps it walks through
  1. Prompt
  2. Triggers
More from AutoSkill
All skills →
About this skill
What does the Backtrader回测特定指标提取与计算 skill do?

在Backtrader回测结束后,配置分析器并计算自定义指标,以输出年度收益、回撤、SQN、卡玛比率、成功率及资金增长率。

How do I install it?

Run `npx skills add ECNU-ICALK/AutoSkill --skill backtrader回测特定指标提取与计算 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going