fix:修改tushare接口为vip接口,需要5000积分以上。

This commit is contained in:
2026-08-03 16:41:14 +08:00
parent 7a5a109b4f
commit b9e288b0a6
2 changed files with 13 additions and 13 deletions
+12 -12
View File
@@ -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: