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:
@@ -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:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user