fix(data): index_downloader baostock error_code判断修(真实为'0'非'success',容两者)——mock与真实baostock分歧
This commit is contained in:
@@ -24,7 +24,7 @@ def download_index(symbol: str, start_year: int, end_year: int, out_dir: str) ->
|
||||
|
||||
# 登录 baostock
|
||||
lg = bs.login()
|
||||
if lg.error_code != "success":
|
||||
if lg.error_code not in ("0", "success"):
|
||||
raise RuntimeError(f"baostock 登录失败: {lg.error_msg}")
|
||||
|
||||
try:
|
||||
@@ -44,13 +44,13 @@ def download_index(symbol: str, start_year: int, end_year: int, out_dir: str) ->
|
||||
adjustfield="3" # 不复权
|
||||
)
|
||||
|
||||
if rs.error_code != "success":
|
||||
if rs.error_code not in ("0", "success"):
|
||||
print(f"Warning: 下载 {symbol} {year} 失败: {rs.error_msg}")
|
||||
continue
|
||||
|
||||
# 转换为 DataFrame
|
||||
data_list = []
|
||||
while (rs.error_code == "success") and rs.next():
|
||||
while (rs.error_code in ("0", "success")) and rs.next():
|
||||
data_list.append(rs.get_row_data())
|
||||
|
||||
if not data_list:
|
||||
|
||||
Reference in New Issue
Block a user