From b9e288b0a646b00acf15d5d811a0a43ae94067d2 Mon Sep 17 00:00:00 2001 From: shellway-pc <413209390@qq.com> Date: Mon, 3 Aug 2026 16:41:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E6=94=B9tushare=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=B8=BAvip=E6=8E=A5=E5=8F=A3=EF=BC=8C=E9=9C=80=E8=A6=815000?= =?UTF-8?q?=E7=A7=AF=E5=88=86=E4=BB=A5=E4=B8=8A=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- quantitative_data/importer.py | 24 ++++++++++++------------ quantitative_data/数据批量导入.ipynb | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/quantitative_data/importer.py b/quantitative_data/importer.py index 08f81b9..ec70572 100644 --- a/quantitative_data/importer.py +++ b/quantitative_data/importer.py @@ -313,7 +313,7 @@ def import_daily_for_stock(ts_code: str, start_date: str, end_date: str, conn) - pro = get_ts_pro() def fetch(): - return pro.daily( + return pro.daily_vip( ts_code=ts_code, start_date=start_date.replace("-", ""), end_date=end_date.replace("-", ""), @@ -371,7 +371,7 @@ def import_daily_by_date( ): """ 按交易日批量导入日线行情 (高效模式) - 使用 pro.daily(trade_date='YYYYMMDD') 一次性拉取全市场当日数据 + 使用 pro.daily_vip(trade_date='YYYYMMDD') 一次性拉取全市场当日数据 大幅减少 API 调用次数: 约250交易日/年 × 16年 ≈ 4000次 (原来需要 5000股票 × 16年 = 80000次) 参数: @@ -462,7 +462,7 @@ def import_daily_by_date( td_str = td.strftime("%Y%m%d") if hasattr(td, "strftime") else str(td).replace("-", "") def fetch(): - return pro.daily(trade_date=td_str) + return pro.daily_vip(trade_date=td_str) df = fetch_with_retry(fetch, max_retries=3) if df is None or df.empty: @@ -565,7 +565,7 @@ def import_daily_basic( kwargs["trade_date"] = trade_date.replace("-", "") def fetch(): - return pro.daily_basic(**kwargs) + return pro.daily_basic_vip(**kwargs) df = fetch_with_retry(fetch, max_retries=2) if df is None or df.empty: @@ -631,7 +631,7 @@ def import_daily_basic_by_date( pro = get_ts_pro() def fetch_daily_basic(): - return pro.daily_basic(trade_date=td) + return pro.daily_basic_vip(trade_date=td) df = fetch_with_retry(fetch_daily_basic, max_retries=3) if df is not None and not df.empty: @@ -685,7 +685,7 @@ def import_adj_factor( kwargs["ts_code"] = ts_code def fetch(): - return pro.adj_factor(**kwargs) + return pro.adj_factor_vip(**kwargs) df = fetch_with_retry(fetch, max_retries=2) if df is None or df.empty: @@ -770,10 +770,10 @@ def import_financial_statements( for i, ts_code in enumerate(stock_list, 1): for table_name, fetch_method in [ - ("income", pro.income), - ("balancesheet", pro.balancesheet), - ("cashflow", pro.cashflow), - ("fina_indicator", pro.fina_indicator), + ("income", pro.income_vip), + ("balancesheet", pro.balancesheet_vip), + ("cashflow", pro.cashflow_vip), + ("fina_indicator", pro.fina_indicator_vip), ]: try: if table_name == "fina_indicator": @@ -855,7 +855,7 @@ def import_index_daily( for idx_code in index_codes: try: def fetch(): - return pro.index_daily( + return pro.index_daily_vip( ts_code=idx_code, start_date=start_date.replace("-", ""), end_date=end_date.replace("-", ""), @@ -1268,7 +1268,7 @@ def resume_daily_by_date( td_compact = td_str.replace("-", "") def fetch(): - return pro.daily(trade_date=td_compact) + return pro.daily_vip(trade_date=td_compact) df = fetch_with_retry(fetch, max_retries=3) if df is None or df.empty: diff --git a/quantitative_data/数据批量导入.ipynb b/quantitative_data/数据批量导入.ipynb index feac19d..ee3cb8a 100644 --- a/quantitative_data/数据批量导入.ipynb +++ b/quantitative_data/数据批量导入.ipynb @@ -260,7 +260,7 @@ "---\n", "## Step 4: 导入日线行情 (核心表,最耗时)\n", "\n", - "> **新版改进:** 按交易日循环拉取全市场数据 `pro.daily(trade_date='20180810')`,\n", + "> **新版改进:** 按交易日循环拉取全市场数据 `pro.daily_vip(trade_date='20180810')`(VIP接口),\n", "> API 调用从 ~80,000次 (5000只×16年) 降至 ~4,000次 (250交易日×16年),速度提升约 **20倍**。\n", "\n", "### 4.1 按年批量导入 (推荐)\n",