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",