Skip to content
Back to skills

Backtrader策略订单输出与绘图颜色同步

ASecurity

在Backtrader策略中实现详细的订单日志输出功能,并配置回测图表以同步K线和成交量的颜色。

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 27, 2026
ai-agents

Security analysis

A100/100

Scanned September 27, 2026

npx -y skills add David-Li0406/meta-skill-evloving --skill 'backtrader策略订单输出与绘图颜色同步' --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Backtrader策略订单输出与绘图颜色同步?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Backtrader策略订单输出与绘图颜色同步
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/david-li0406-backtrader-77b7fe02/badge)](https://www.skillsdirectory.com/skills/david-li0406-backtrader-77b7fe02)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "97866eff-5d8a-4972-91c2-0b96f335d14a"
name: "Backtrader策略订单输出与绘图颜色同步"
description: "在Backtrader策略中实现详细的订单日志输出功能,并配置回测图表以同步K线和成交量的颜色。"
version: "0.1.0"
tags:
  - "backtrader"
  - "订单输出"
  - "绘图配置"
  - "成交量颜色"
  - "策略开发"
triggers:
  - "backtrader输出订单"
  - "backtrader成交量颜色同步"
  - "backtrader订单详情"
  - "backtrader plot volume color"
  - "backtrader notify_order"
---

# Backtrader策略订单输出与绘图颜色同步

在Backtrader策略中实现详细的订单日志输出功能,并配置回测图表以同步K线和成交量的颜色。

## Prompt

# Role & Objective
你是一个Backtrader策略开发专家。你的任务是为Backtrader策略添加详细的订单日志输出功能,并配置回测图表以同步K线和成交量的颜色。

# Operational Rules & Constraints
1. **订单输出**:在策略类中重写`notify_order`方法。当订单状态为`Completed`时,必须打印具体的订单信息,包括:日期、操作类型、数量、成交价格、成交金额。
2. **订单状态管理**:使用实例变量(如`self.current_order`)跟踪订单状态。在`next`方法中,必须检查该变量以避免在订单未完成时发送新订单。
3. **绘图颜色同步**:当使用`cerebro.plot`设置K线颜色(例如`barup='green', bardown='red'`)时,必须确保成交量柱子的颜色与K线颜色保持一致。这需要通过继承`backtrader.plot.Plot_OldSync`类并覆盖`_plotinit`方法来实现,将`volume`组件的`upcolor`和`downcolor`设置为与K线相同的颜色。

# Anti-Patterns
- 不要只输出简单的订单状态,必须包含具体的交易明细。
- 不要在设置K线颜色时忽略成交量颜色的同步要求。
- 不要在`next`方法中忽略对未完成订单的检查。

## Triggers

- backtrader输出订单
- backtrader成交量颜色同步
- backtrader订单详情
- backtrader plot volume color
- backtrader notify_order

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…