fix: 修复数据获取架构逻辑Bug

修复内容:

1. Bug #1: TushareSource.fetch(adj='raw') ETF 无法获取
   - 在 adj='raw' 分支优先判断 ETF
   - ETF 代码现在正确路由到 fetch_etf()

2. Bug #2: is_china_index 判断范围过宽
   - 添加 ETF 排除逻辑
   - ETF 不再被误判为指数

3. 接口一致性:CCXTSource 添加 adj 参数
   - fetch(code, start, end, adj='raw', timeframe)
   - 加密货币仅支持 adj='raw'
   - UniversalDataFetcher._fetch_crypto() 同步更新

影响:
- ETF 原始价格数据获取恢复正常
- 类型判断逻辑更准确
- 数据源接口签名统一
This commit is contained in:
2026-05-23 21:46:01 +08:00
parent b7f7a756b6
commit 3697c9d38b
3 changed files with 19 additions and 4 deletions

View File

@@ -188,7 +188,10 @@ class TushareSource:
return None
def is_china_index(self, code: str) -> bool:
"""判断是否为A股指数"""
"""判断是否为A股指数(排除 ETF"""
# 先排除 ETF
if self._is_etf_code(code):
return False
return code.endswith(".SH") or code.endswith(".SZ") or code.endswith(".SS") or code.endswith(".CSI")
def is_futures(self, code: str) -> bool:
@@ -237,7 +240,10 @@ class TushareSource:
# 原始数据
if adj == 'raw':
if self.is_china_index(code):
# 优先判断 ETF修复ETF 原始数据获取)
if self._is_etf_code(code):
return self.fetch_etf(code, start_date, end_date)
elif self.is_china_index(code):
return self.fetch_index(code, start_date, end_date)
elif self.is_futures(code):
return self.fetch_futures(code, start_date, end_date)