update
This commit is contained in:
parent
349bc9c720
commit
303f938bd7
@ -191,7 +191,35 @@ class DingTalkBot:
|
||||
if isinstance(market_sentiment, (dict, list)):
|
||||
market_sentiment = self._format_complex_content(market_sentiment)
|
||||
|
||||
# 处理总结字段 - 检查是否为字符串形式的JSON并尝试解析
|
||||
summary = analysis_result.get('summary', '无摘要')
|
||||
if isinstance(summary, str) and (summary.startswith('{') or summary.startswith('{')):
|
||||
try:
|
||||
# 尝试解析JSON字符串
|
||||
summary_json = json.loads(summary)
|
||||
formatted_summary = ""
|
||||
|
||||
# 添加概述
|
||||
if 'overview' in summary_json:
|
||||
formatted_summary += f"**总体概述**:{summary_json['overview']}\n\n"
|
||||
|
||||
# 添加关键点
|
||||
if 'key_points' in summary_json and isinstance(summary_json['key_points'], list):
|
||||
formatted_summary += "**关键点**:\n"
|
||||
for point in summary_json['key_points']:
|
||||
formatted_summary += f"- {point}\n"
|
||||
formatted_summary += "\n"
|
||||
|
||||
# 添加交易建议
|
||||
if 'trading_suggestion' in summary_json:
|
||||
formatted_summary += f"**交易建议**:{summary_json['trading_suggestion']}"
|
||||
|
||||
summary = formatted_summary
|
||||
except Exception as e:
|
||||
# 如果解析失败,保留原始内容
|
||||
print(f"解析summary JSON时出错: {e}")
|
||||
elif isinstance(summary, (dict, list)):
|
||||
summary = self._format_complex_content(summary)
|
||||
|
||||
# 根据市场趋势设置颜色标志
|
||||
if '牛' in str(market_trend) or 'bull' in str(market_trend).lower():
|
||||
@ -216,7 +244,8 @@ class DingTalkBot:
|
||||
**市场情绪**:
|
||||
{market_sentiment}
|
||||
|
||||
**总结**: {summary}
|
||||
**总结**:
|
||||
{summary}
|
||||
|
||||
*分析时间: {time.strftime('%Y-%m-%d %H:%M:%S')}*
|
||||
"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user