1
0
Files
leopard-analysis/openspec/changes/archive/2026-01-28-add-macd-strategy/proposal.md
2026-01-28 00:10:43 +08:00

35 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## Why
当前项目仅包含SMA双均线交叉策略`strategies/sma_strategy.py`需要引入基于MACD的趋势跟踪策略。MACD作为经典动量指标结合EMA200趋势过滤在A股市场表现优异能更准确地捕捉趋势启动点和反转信号。
## What Changes
- 创建 `strategies/macd_strategy.py` - 新增MACD趋势跟踪策略文件
- 实现MACD指标计算 - 使用ta-lib库计算MACD(10,20,9)指标和EMA200趋势线
- 实现策略交易逻辑 - MACD金叉/死叉信号 + EMA200趋势确认
- 保持策略文件独立性 - 按照现有`strategy.py`模式实现calculate_indicators、get_strategy、Strategy类
- 创建strategies目录 - 用于统一管理所有策略脚本
## Capabilities
### New Capabilities
- `macd-trading`: MACD趋势跟踪策略包含MACD指标计算、EMA200趋势过滤、以及基于金叉/死叉的交易信号生成
### Modified Capabilities
## Impact
**依赖变化**:
- ta-lib已手动安装用于技术指标计算
**代码影响**:
- 不需要修改现有代码(`backtest.py`无需改动,策略文件模式保持一致)
- 策略目录扩展至2个策略文件
- 可通过`--strategy-file`参数切换使用SMA或MACD策略
**系统影响**:
- 回测框架保持不变
- 现有SMA策略完全不受影响
- 可通过backtest.py的标准接口加载MACD策略