From fdee4bbfd48ffbc82628023973c8802d543d642e Mon Sep 17 00:00:00 2001
From: log
Date: Fri, 10 Jul 2026 07:45:17 +0800
Subject: [PATCH] fix: map 920 bse stocks to baostock bj codes
---
a_stock_manager.py | 51 ++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 42 insertions(+), 9 deletions(-)
diff --git a/a_stock_manager.py b/a_stock_manager.py
index ae2e11e..a3aff8a 100644
--- a/a_stock_manager.py
+++ b/a_stock_manager.py
@@ -183,23 +183,23 @@
"""打印信息消息"""
print(f"{Color.OKCYAN}ℹ {text}{Color.ENDC}")
-def run_script(script_name, description="", return_result=False):
+def run_script(script_name, description="", return_result=False, args=None):
"""运行脚本"""
if description:
print_info(f"正在执行: {description}")
script_path = scripts_dir / script_name
+ command = [sys.executable, str(script_path)]
+ if args:
+ command.extend(args)
+
try:
result = subprocess.run(
- [sys.executable, str(script_path)],
+ command,
cwd=project_root,
- capture_output=True,
+ capture_output=False,
text=True
)
- if result.stdout:
- print(result.stdout)
- if result.stderr:
- print_error(result.stderr)
-
+
if return_result:
result_file = project_root / 'logs' / 'script_result.json'
if result_file.exists():
@@ -213,6 +213,32 @@
except Exception as e:
print_error(f"执行失败: {e}")
return False
+
+
+def prompt_stock_count_args():
+ """选择数据更新股票数量,并返回传给数据更新脚本的参数。"""
+ print(f"\n{Color.BOLD}【股票数量】{Color.ENDC}")
+ print("1. 快速更新 500 只股票 ⭐推荐")
+ print("2. 全量更新全部A股(较慢)")
+ print("3. 自定义数量")
+ print("0. 返回")
+
+ choice = input("\n请选择股票数量 (0-3): ").strip()
+ if choice == '1':
+ return ["--n-stocks", "500"], "500只股票"
+ if choice == '2':
+ return ["--n-stocks", "all"], "全量A股"
+ if choice == '3':
+ value = input("请输入股票数量: ").strip()
+ if not value.isdigit() or int(value) <= 0:
+ print_error("股票数量必须是正整数")
+ return None, None
+ return ["--n-stocks", value], f"{value}只股票"
+ if choice == '0':
+ return None, None
+
+ print_error("无效的选择")
+ return None, None
def run_enhanced_factor_system(data_file=None):
"""运行增强因子系统"""
@@ -344,7 +370,14 @@
run_enhanced_factor_system()
return result
elif choice == '3':
- result = run_script('data_update_v2.py', "从AKShare在线获取数据")
+ args, stock_count_desc = prompt_stock_count_args()
+ if args is None:
+ return False
+ result = run_script(
+ 'data_update_v2.py',
+ f"从AKShare在线获取数据({stock_count_desc})",
+ args=args,
+ )
if result:
print_info("数据更新完成,正在运行增强因子系统...")
run_enhanced_factor_system()
--
Gitblit v1.8.0