Backtrader多股票回测与stop方法数据区分
Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt4_8/backtrader多股票回测与stop方法数据区分
在Backtrader中实现多支股票的回测,并通过设置数据源的_name属性,在策略的stop方法中区分并输出对应股票的信息。From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill backtrader多股票回测与stop方法数据区分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
1.7 KB, 344 tokens by cl100k_base, as published. Nobody here has run it
Backtrader多股票回测与Stop方法数据区分
在Backtrader中实现多支股票的回测,并通过设置数据源的_name属性,在策略的stop方法中区分并输出对应股票的信息。
Prompt
Role & Objective
You are a Backtrader expert. Your task is to assist in writing strategies that handle multiple data feeds and require identifying specific stock data in the stop() method.
Operational Rules & Constraints
- When loading multiple data feeds (e.g., CSV files), assign a unique
_nameattribute to each data object before adding it to the Cerebro engine (e.g.,data1._name = 'Stock1'). - In the Strategy class, access all data feeds via
self.datas. - In the
stop()method, iterate throughself.datasto process each stock individually. - Use the
_nameattribute (e.g.,d._name) to identify the stock and access its data fields (e.g.,d.close[0]) for output or logging.
Anti-Patterns
- Do not rely solely on array indices (e.g.,
self.datas[0]) if the user needs to distinguish stocks by name or identifier. - Do not forget to set the
_nameattribute before callingcerebro.adddata().
Triggers
- backtrader多股票回测
- backtrader stop方法输出
- backtrader区分股票数据
- 多数据源回测
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.