update
This commit is contained in:
parent
098ba1ad78
commit
349bc9c720
Binary file not shown.
@ -519,4 +519,34 @@ class CryptoAgent:
|
||||
except Exception as e:
|
||||
print(f"智能体运行时出错: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
traceback.print_exc()
|
||||
|
||||
def send_notifications(self, symbol: str, analysis_data: Dict[str, Any]) -> bool:
|
||||
"""
|
||||
发送分析结果通知
|
||||
|
||||
Args:
|
||||
symbol: 交易对符号
|
||||
analysis_data: 分析数据
|
||||
|
||||
Returns:
|
||||
发送是否成功
|
||||
"""
|
||||
if not self.dingtalk_bot:
|
||||
print(f"钉钉通知未启用,跳过发送 {symbol} 的分析结果")
|
||||
return False
|
||||
|
||||
try:
|
||||
# 使用已初始化的钉钉机器人实例发送完整分析报告
|
||||
response = self.dingtalk_bot.send_analysis_report(symbol, analysis_data)
|
||||
|
||||
if response.get('errcode') == 0:
|
||||
print(f"成功发送 {symbol} 分析结果到钉钉")
|
||||
return True
|
||||
else:
|
||||
print(f"发送 {symbol} 分析结果到钉钉失败: {response}")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
print(f"发送钉钉通知时出错: {e}")
|
||||
return False
|
||||
@ -12,11 +12,11 @@ deepseek:
|
||||
# 加密货币设置
|
||||
crypto:
|
||||
base_currencies:
|
||||
- "BTC"
|
||||
# - "BTC"
|
||||
- "ETH"
|
||||
- "BNB"
|
||||
# - "BNB"
|
||||
- "SOL"
|
||||
- "ADA"
|
||||
# - "ADA"
|
||||
quote_currency: "USDT"
|
||||
time_interval: "4h" # 可选: 1m, 5m, 15m, 30m, 1h, 4h, 1d
|
||||
|
||||
|
||||
@ -12,10 +12,10 @@ deepseek:
|
||||
# 加密货币设置
|
||||
crypto:
|
||||
base_currencies:
|
||||
- "BTC"
|
||||
# - "ETH"
|
||||
# - "BNB"
|
||||
# - "SOL"
|
||||
# - "BTC"
|
||||
- "ETH"
|
||||
- "BNB"
|
||||
- "SOL"
|
||||
# - "ADA"
|
||||
quote_currency: "USDT"
|
||||
time_interval: "4h" # 可选: 1m, 5m, 15m, 30m, 1h, 4h, 1d
|
||||
|
||||
@ -114,6 +114,45 @@ class DingTalkBot:
|
||||
traceback.print_exc()
|
||||
return {"errcode": -1, "errmsg": str(e)}
|
||||
|
||||
def _format_complex_content(self, content) -> str:
|
||||
"""
|
||||
格式化复杂内容(JSON对象或列表)为易读的文本
|
||||
|
||||
Args:
|
||||
content: 需要格式化的内容
|
||||
|
||||
Returns:
|
||||
格式化后的文本
|
||||
"""
|
||||
if isinstance(content, dict):
|
||||
# 将字典转换为项目列表
|
||||
formatted_text = ""
|
||||
for key, value in content.items():
|
||||
key_display = key.replace('_', ' ').title()
|
||||
if isinstance(value, (dict, list)):
|
||||
formatted_text += f"- **{key_display}**: \n"
|
||||
# 递归处理嵌套结构
|
||||
nested_text = self._format_complex_content(value)
|
||||
# 增加缩进
|
||||
nested_text = '\n'.join([f" {line}" for line in nested_text.split('\n')])
|
||||
formatted_text += f"{nested_text}\n"
|
||||
else:
|
||||
formatted_text += f"- **{key_display}**: {value}\n"
|
||||
return formatted_text
|
||||
elif isinstance(content, list):
|
||||
# 将列表转换为项目列表
|
||||
formatted_text = ""
|
||||
for item in content:
|
||||
if isinstance(item, (dict, list)):
|
||||
nested_text = self._format_complex_content(item)
|
||||
formatted_text += f"- {nested_text}\n"
|
||||
else:
|
||||
formatted_text += f"- {item}\n"
|
||||
return formatted_text
|
||||
else:
|
||||
# 简单类型直接返回字符串
|
||||
return str(content)
|
||||
|
||||
def format_analysis_result(self, symbol: str, analysis_result: Dict[str, Any]) -> str:
|
||||
"""
|
||||
格式化分析结果为Markdown格式
|
||||
@ -143,14 +182,21 @@ class DingTalkBot:
|
||||
else:
|
||||
resistance_levels_str = str(resistance_levels)
|
||||
|
||||
# 格式化交易量分析和市场情绪
|
||||
volume_analysis = analysis_result.get('volume_analysis', '未知')
|
||||
if isinstance(volume_analysis, (dict, list)):
|
||||
volume_analysis = self._format_complex_content(volume_analysis)
|
||||
|
||||
market_sentiment = analysis_result.get('market_sentiment', '未知')
|
||||
if isinstance(market_sentiment, (dict, list)):
|
||||
market_sentiment = self._format_complex_content(market_sentiment)
|
||||
|
||||
summary = analysis_result.get('summary', '无摘要')
|
||||
|
||||
# 根据市场趋势设置颜色标志
|
||||
if '牛' in market_trend or 'bull' in str(market_trend).lower():
|
||||
if '牛' in str(market_trend) or 'bull' in str(market_trend).lower():
|
||||
trend_icon = "🟢"
|
||||
elif '熊' in market_trend or 'bear' in str(market_trend).lower():
|
||||
elif '熊' in str(market_trend) or 'bear' in str(market_trend).lower():
|
||||
trend_icon = "🔴"
|
||||
else:
|
||||
trend_icon = "🟡"
|
||||
@ -164,9 +210,11 @@ class DingTalkBot:
|
||||
|
||||
**阻力位**: {resistance_levels_str}
|
||||
|
||||
**交易量分析**: {volume_analysis}
|
||||
**交易量分析**:
|
||||
{volume_analysis}
|
||||
|
||||
**市场情绪**: {market_sentiment}
|
||||
**市场情绪**:
|
||||
{market_sentiment}
|
||||
|
||||
**总结**: {summary}
|
||||
|
||||
@ -199,13 +247,18 @@ class DingTalkBot:
|
||||
prediction_24h = prediction_result.get('prediction_24h', {})
|
||||
prediction_7d = prediction_result.get('prediction_7d', {})
|
||||
prediction_30d = prediction_result.get('prediction_30d', {})
|
||||
|
||||
# 处理关键影响因素
|
||||
key_factors = prediction_result.get('key_factors', [])
|
||||
if isinstance(key_factors, list):
|
||||
key_factors_str = '\n'.join([f"- {factor}" for factor in key_factors])
|
||||
else:
|
||||
key_factors_str = str(key_factors)
|
||||
key_factors_str = self._format_complex_content(key_factors)
|
||||
|
||||
# 处理风险评估
|
||||
risk_assessment = prediction_result.get('risk_assessment', '未知')
|
||||
if isinstance(risk_assessment, (dict, list)):
|
||||
risk_assessment = self._format_complex_content(risk_assessment)
|
||||
|
||||
# 格式化预测数据
|
||||
def format_prediction(pred_data):
|
||||
@ -240,7 +293,8 @@ class DingTalkBot:
|
||||
**关键影响因素**:
|
||||
{key_factors_str}
|
||||
|
||||
**风险评估**: {risk_assessment}
|
||||
**风险评估**:
|
||||
{risk_assessment}
|
||||
|
||||
*预测时间: {time.strftime('%Y-%m-%d %H:%M:%S')}*
|
||||
"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user