From f7b60659ab8f39f9da8f23e35cd5c80a51725fcb Mon Sep 17 00:00:00 2001 From: fish Date: Thu, 7 May 2026 22:56:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20Tushare=20=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E7=9A=84=20ts=5Fcode=20=E7=BC=BA=E5=B0=91=E4=BA=A4?= =?UTF-8?q?=E6=98=93=E6=89=80=E5=90=8E=E7=BC=80=E5=AF=BC=E8=87=B4=E6=9F=A5?= =?UTF-8?q?=E4=B8=8D=E5=88=B0=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.7 --- tushare/src/fetcher.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tushare/src/fetcher.py b/tushare/src/fetcher.py index b226e99..b5c50d4 100644 --- a/tushare/src/fetcher.py +++ b/tushare/src/fetcher.py @@ -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: