修复 Tushare 返回的 ts_code 缺少交易所后缀导致查不到数据

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
fish
2026-05-07 22:56:19 +08:00
parent fef806f796
commit f7b60659ab

View File

@@ -34,6 +34,10 @@ def fetch_contract(
]
df = df[[c for c in cols if c in df.columns]].copy()
# 确保 ts_code 列与查询时传入的完整代码一致Tushare 返回的可能不带交易所后缀)
if "ts_code" in df.columns:
df["ts_code"] = ts_code
numeric = ["open", "high", "low", "close", "vol", "amount", "oi", "oi_chg", "pre_close"]
for c in numeric:
if c in df.columns: