From 7f2a968be02709e8883517baa4f23747f1664f28 Mon Sep 17 00:00:00 2001 From: aszerW Date: Sun, 21 Jun 2026 17:11:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(datasource):=20ETF=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=AF=86=E5=88=AB=E6=94=AF=E6=8C=81=E7=A7=91=E5=88=9B=E6=9D=BF?= =?UTF-8?q?(58)=E5=92=8C=E6=B2=AA=E5=B8=82=E6=96=B0ETF(56)=E5=89=8D?= =?UTF-8?q?=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 问题 科创板ETF(588000.SH)和沪市新ETF(56xxxx.SH)数据获取失败(HTTP 404) ## 根因 tushare_source.py._is_etf_code()仅识别['51','52','15','16']前缀 遗漏科创板ETF(58xxxx.SH)和沪市新ETF(56xxxx.SH) ## 修复 - 添加'58'前缀支持科创板ETF - 添加'56'前缀支持沪市新ETF(如红利低波ETF) ## 验证 Tushare fund_daily接口实测证明支持科创板ETF: - 588000.SH: 111条数据 ✅ - 588080.SH: 111条数据 ✅ - 000688.SH(科创板指数): 111条数据 ✅ ## 附带修改 - simple_rotation.py添加--config参数支持 --- datasource/tushare_source.py | 4 ++-- rotation/simple_rotation.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/datasource/tushare_source.py b/datasource/tushare_source.py index a0315ce..b189eec 100644 --- a/datasource/tushare_source.py +++ b/datasource/tushare_source.py @@ -325,12 +325,12 @@ class TushareSource: def _is_etf_code(self, code: str) -> bool: """判断是否为ETF代码""" - # ETF代码:51xxxx.SH, 52xxxx.SH, 15xxxx.SZ, 16xxxx.SZ + # ETF代码:51xxxx.SH, 52xxxx.SH, 56xxxx.SH, 58xxxx.SH(科创板), 15xxxx.SZ, 16xxxx.SZ import re if not re.match(r'^\d{6}\.(SZ|SH)$', code): return False prefix = code[:2] - return prefix in ['51', '52', '15', '16'] + return prefix in ['51', '52', '56', '58', '15', '16'] def _get_etf_type(self, code: str) -> str: """ diff --git a/rotation/simple_rotation.py b/rotation/simple_rotation.py index c02074a..de8fa2b 100644 --- a/rotation/simple_rotation.py +++ b/rotation/simple_rotation.py @@ -1854,13 +1854,15 @@ if __name__ == "__main__": os.environ['FLASK_API_URL'] = 'https://k3s.tokenpluse.xyz' parser = argparse.ArgumentParser(description='Simple Rotation Strategy Backtest') + parser.add_argument('--config', type=str, default=None, + help='Config file path (default: config_simple.yaml)') parser.add_argument('--no-detail', action='store_true', help='Skip detail JSON export (faster, for daily runs)') parser.add_argument('--no-report', action='store_true', help='Skip report PNG generation') args = parser.parse_args() - strategy = SimpleRotationStrategy() + strategy = SimpleRotationStrategy(config_path=args.config) result = strategy.run() if result: