- 使用 fetch_all() 替代 fetch_batch() - 添加 from dotenv import load_dotenv 加载环境变量 - 返回完整数据结构(index_data, etf_data, nav_data, benchmark) 回测验证成功: - 累计收益: 164.47% - 最终净值: 2.6447 - 信号日期: 1780 天
重构 RotationStrategy: - 添加 from_yaml() 从配置创建实例 - 添加 get_data() 获取数据 - 添加 compute_factors() 计算因子 - 添加 generate_signals() 生成信号 - 添加 run_backtest() 完整回测流程 简化 run_rotation.py: - 从 264 行简化为 9 行 - 只做策略调用入口 执行方式: python run_rotation.py --config config/strategies/rotation.yaml python run_rotation.py --save-path results/my_rotation 代码方式: strategy = RotationStrategy.from_yaml('config/strategies/rotation.yaml') result = strategy.run_backtest()
- RotationStrategy: 继承StrategyBase,使用MomentumFactor+TopNSelector - 实现before_entry溢价过滤、dynamic_stoploss动态止损、custom_exit自定义出场 - 策略配置从类属性读取,支持config覆盖