Files
etf/rotation/README_SIMPLE.md
aszerW 451ffa33d2 clean(rotation): add simple rotation strategy and remove unused files
New:
- rotation/simple_rotation.py: daily-iteration rotation strategy (584 lines)
- rotation/config_loader.py: standalone config loader
- rotation/config_simple.yaml: 11 assets, 7 groups
- rotation/README_SIMPLE.md: usage guide
- scripts/get_trading_calendar.py: trading calendar fetcher

Removed:
- rotation/example_usage.py, run_strategy.py (replaced by simple_rotation.py)
- rotation/results/ output files (gitignored)
- scripts/verify_*.py, calculate_returns_from_detail.py (one-off scripts)
- scripts/README_TRADING_CALENDAR.md

Backtest result (2020-01-10 ~ 2026-06-01):
- Total return: 1237.6%, Annual: 52.66%
- Max drawdown: -11.71%, Sharpe: 2.50
2026-06-01 22:28:26 +08:00

1.8 KiB
Raw Permalink Blame History

精简版轮动策略(日迭代)

概述

从 A 股交易日历出发,逐日迭代模拟实盘信号生成流程。

与 V2 的核心差异:

特性 V2 向量化版本 精简版(日迭代)
数据获取 一次性获取所有历史数据 预加载+CSV缓存
因子计算 全量 rolling 计算 每日单独计算
日历对齐 先算因子,后对齐 从 A 股日历出发
收益计算 向量化 逐日迭代

快速使用

cd /path/to/etf
FLASK_API_URL=https://k3s.tokenpluse.xyz python rotation/simple_rotation.py

或作为模块导入:

from rotation.simple_rotation import SimpleRotationStrategy

strategy = SimpleRotationStrategy('rotation/config_simple.yaml')
result = strategy.run()
strategy.export_results()

策略逻辑

动量计算

  • 加权线性回归:score = annualized_return * R^2
  • 窗口25 天(可配置)
  • 崩盘过滤:连续 3 天跌 > 5% 则清零

信号生成(与 V2 完全一致)

  1. 每个 group 内选 Top 1非 BOND 组需超过短债动量)
  2. 从各组 Top 1 中按动量排序选 Top 3
  3. 不足用 BOND 填充

T+1 执行收益

  • 持有日: close-to-close
  • 卖出日: close-to-open开盘已卖出
  • 买入日: open-to-close日内收益
  • 调仓日扣除 0.1% 交易成本

输出文件

results/
├── simple_rotation_nav.csv       # 净值曲线
├── simple_rotation_signals.csv   # 每日信号
├── simple_rotation_detail.json   # 完整详情
└── simple_rotation_metrics.json  # 绩效指标

数据缓存

首次运行会从 Flask API 下载数据并缓存到 data/simple_rotation_cache/。 后续运行直接读取缓存,速度显著提升。