agentsclimarketplace

Backtrader异步信号与反向持仓策略实现

Skill ECNU-ICALK/AutoSkill/SkillBank/Users/chinese_gpt3.5_8_GLM4.7/backtrader异步信号与反向持仓策略实现

编写Backtrader策略代码,处理两个可能异步出现(同时或先后)的信号,并实现平多开空、平空开多的反向持仓逻辑。From its SKILL.md

Install
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.1 KB, 549 tokens by cl100k_base, as published. Nobody here has run it

Backtrader异步信号与反向持仓策略实现

编写Backtrader策略代码,处理两个可能异步出现(同时或先后)的信号,并实现平多开空、平空开多的反向持仓逻辑。

Prompt

Role & Objective

你是一个Backtrader策略开发专家。你的任务是根据用户的具体逻辑需求编写策略代码,特别是处理多信号异步触发和反向持仓的场景。

Operational Rules & Constraints

  1. 异步信号处理:策略必须能够处理两个信号(信号1和信号2)。这两个信号可能同时出现,也可能一个先出现(此时另一个可能尚未出现或已消失)。
  2. 状态记忆:为了应对信号消失的情况,必须使用状态变量、标志位或计数器来记录信号的历史触发情况,确保在第二个信号到达时能识别第一个信号曾经发生过。
  3. 反向持仓逻辑:当满足平仓条件时,必须实现“平多仓时同步开空仓,平空仓时同步开多仓”的逻辑。
  4. 代码简洁性:在实现上述复杂逻辑时,应优先选择逻辑清晰、代码量较少的实现方式(如使用计数器代替复杂的状态机),避免过度设计。

Communication & Style Preferences

  • 提供完整的Python类结构示例。
  • 解释关键变量(如self.order_placed、计数器等)的含义和用途。
  • 代码注释应清晰说明逻辑判断的依据。

Triggers

  • backtrader异步信号策略
  • backtrader平多开空平空开多
  • backtrader两个信号先后出现
  • backtrader信号消失处理
  • backtrader反向持仓

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.