修复 Tushare 返回的 ts_code 缺少交易所后缀导致查不到数据
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -34,6 +34,10 @@ def fetch_contract(
|
|||||||
]
|
]
|
||||||
df = df[[c for c in cols if c in df.columns]].copy()
|
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"]
|
numeric = ["open", "high", "low", "close", "vol", "amount", "oi", "oi_chg", "pre_close"]
|
||||||
for c in numeric:
|
for c in numeric:
|
||||||
if c in df.columns:
|
if c in df.columns:
|
||||||
|
|||||||
Reference in New Issue
Block a user