This commit is contained in:
aaron 2026-02-11 22:46:27 +08:00
parent a0c2340170
commit d16c5562de
2 changed files with 51 additions and 3 deletions

View File

@ -153,6 +153,8 @@ class QuestionAnalyzer:
2. **股票识别**如果是stock_analysis这是最重要的部分
请识别用户提到的股票并返回准确的股票代码
**重要**如果用户提到多只股票"TSLA和NVDA""特斯拉、英伟达"请返回所有股票代码的列表
**A股代码格式**6位数字
- 上海主板600xxx601xxx603xxx605xxx
- 深圳主板000xxx001xxx
@ -161,7 +163,7 @@ class QuestionAnalyzer:
- 常见示例贵州茅台600519比亚迪002594宁德时代300750
**美股代码格式**1-5位大写字母
- 常见示例苹果AAPL特斯拉TSLA微软MSFT谷歌GOOGL
- 常见示例苹果AAPL特斯拉TSLA微软MSFT谷歌GOOGL英伟达NVDA
- 中概股美股阿里巴巴美股BABA京东美股JD拼多多PDD百度美股BIDU网易美股NTES哔哩哔哩美股BILI
**港股代码格式**4-5位数字加.HK后缀
@ -215,8 +217,8 @@ class QuestionAnalyzer:
{{
"type": "问题类型",
"target": {{
"stock_code": "股票代码A股返回6位数字如600519美股返回大写字母如BABA港股返回带.HK后缀如0700.HK",
"stock_name": "股票/公司名称(如贵州茅台、阿里巴巴、腾讯",
"stock_code": "单只股票时为字符串(如'AAPL'),多只股票时为列表(如['TSLA', 'NVDA']",
"stock_name": "单只股票时为字符串(如'苹果'),多只股票时为列表(如['特斯拉', '英伟达']",
"market": "A股/美股/港股"
}},
"dimensions": {{

View File

@ -2917,6 +2917,52 @@ MACD{f"{technical.get('macd'):.4f}" if technical.get('macd') else '计算中'
yield f"抱歉,我没有识别到您提到的股票「{stock_name or ''}」。请提供更明确的股票代码或名称。"
return
# 检查是否返回了多个股票代码(列表)
if isinstance(stock_code, list):
# 如果是多个股票,依次分析每一个
if len(stock_code) == 0:
yield "抱歉,我没有识别到有效的股票代码。"
return
elif len(stock_code) == 1:
# 只有一个股票,提取出来
stock_code = stock_code[0]
if isinstance(stock_name, list) and len(stock_name) > 0:
stock_name = stock_name[0]
else:
# 多个股票,依次分析每一个
stock_codes = stock_code
stock_names = stock_name if isinstance(stock_name, list) else [stock_name] * len(stock_codes)
yield f"检测到您想查询 {len(stock_codes)} 只股票:{', '.join(stock_codes)}\n\n"
yield f"我将为您依次分析这些股票:\n\n"
# 循环分析每只股票
for i, (code, name) in enumerate(zip(stock_codes, stock_names), 1):
yield f"{'=' * 60}\n"
yield f"{i}/{len(stock_codes)}】分析 {name}{code}\n"
yield f"{'=' * 60}\n\n"
# 根据市场类型处理
if market == '美股':
async for chunk in self._handle_us_stock_stream_with_code(code, name or code, message):
yield chunk
elif market == '港股':
async for chunk in self._handle_hk_stock_stream_with_code(code, name or code, message):
yield chunk
else:
# A股处理
async for chunk in self._handle_a_stock_stream(code, message):
yield chunk
# 在股票之间添加分隔
if i < len(stock_codes):
yield f"\n\n"
yield f"\n\n{'=' * 60}\n"
yield f"✅ 已完成 {len(stock_codes)} 只股票的分析\n"
yield f"{'=' * 60}\n"
return
# 根据市场类型处理
if market == '美股':
# 美股处理流程