fix(datasource): ETF代码识别支持科创板(58)和沪市新ETF(56)前缀

## 问题
科创板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参数支持
This commit is contained in:
2026-06-21 17:11:45 +08:00
parent 2716eec511
commit 7f2a968be0
2 changed files with 5 additions and 3 deletions

View File

@@ -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:
"""

View File

@@ -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: