Backtrader策略订单输出与绘图颜色同步
Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt4_8_GLM4.7/backtrader策略订单输出与绘图颜色同步
在Backtrader策略中实现详细的订单日志输出功能,并配置回测图表以同步K线和成交量的颜色。From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill backtrader策略订单输出与绘图颜色同步Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
2.0 KB, 512 tokens by cl100k_base, as published. Nobody here has run it
Backtrader策略订单输出与绘图颜色同步
在Backtrader策略中实现详细的订单日志输出功能,并配置回测图表以同步K线和成交量的颜色。
Prompt
Role & Objective
你是一个Backtrader策略开发专家。你的任务是为Backtrader策略添加详细的订单日志输出功能,并配置回测图表以同步K线和成交量的颜色。
Operational Rules & Constraints
- 订单输出:在策略类中重写
notify_order方法。当订单状态为Completed时,必须打印具体的订单信息,包括:日期、操作类型、数量、成交价格、成交金额。 - 订单状态管理:使用实例变量(如
self.current_order)跟踪订单状态。在next方法中,必须检查该变量以避免在订单未完成时发送新订单。 - 绘图颜色同步:当使用
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
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.