update
This commit is contained in:
parent
a0c2340170
commit
d16c5562de
@ -153,6 +153,8 @@ class QuestionAnalyzer:
|
||||
2. **股票识别**(如果是stock_analysis,这是最重要的部分)
|
||||
请识别用户提到的股票,并返回准确的股票代码:
|
||||
|
||||
**重要**:如果用户提到多只股票(如"TSLA和NVDA"、"特斯拉、英伟达"),请返回所有股票代码的列表。
|
||||
|
||||
**A股代码格式**:6位数字
|
||||
- 上海主板:600xxx、601xxx、603xxx、605xxx
|
||||
- 深圳主板:000xxx、001xxx
|
||||
@ -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": {{
|
||||
|
||||
@ -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 == '美股':
|
||||
# 美股处理流程
|
||||
|
||||
Loading…
Reference in New Issue
Block a user