This commit is contained in:
aaron 2026-02-06 22:03:59 +08:00
parent dba001e624
commit ead82a4554
2 changed files with 55 additions and 162 deletions

View File

@ -161,83 +161,39 @@ class FeishuService:
# 等级图标 # 等级图标
grade_icon = {'A': '⭐⭐⭐', 'B': '⭐⭐', 'C': '', 'D': ''}.get(signal_grade, '') grade_icon = {'A': '⭐⭐⭐', 'B': '⭐⭐', 'C': '', 'D': ''}.get(signal_grade, '')
type_short = "短线" if signal_type == 'short_term' else "波段"
# 构建内容 # 构建精简内容 - 突出核心交易信息
content_parts = [ content_parts = [
f"**信号类型**: {type_text} {type_hint}", f"**{type_short}** | {signal_grade}{grade_icon} | {confidence}% | {trend_text}",
f"**信号等级**: {signal_grade} {grade_icon}", f"**入场**: ${price:,.2f}",
f"**当前价格**: ${price:,.2f}",
f"**趋势方向**: {trend_text}",
f"**置信度**: {confidence}%",
] ]
# 添加触发原因 # 止损止盈(核心点位)
if reasons:
content_parts.extend([
"",
"---",
"",
"**触发原因**:",
])
for reason in reasons[:5]: # 最多显示5个原因
content_parts.append(f"{reason}")
content_parts.extend([
"",
"---",
"",
"**技术指标**:"
])
# 添加技术指标
if indicators:
rsi = indicators.get('rsi', 0)
macd = indicators.get('macd', 0)
macd_signal = indicators.get('macd_signal', 0)
rsi_status = "超卖 ↑" if rsi < 30 else ("超买 ↓" if rsi > 70 else "中性")
macd_status = "金叉" if macd > macd_signal else "死叉"
content_parts.extend([
f"• RSI(14): {rsi:.1f} ({rsi_status})",
f"• MACD: {macd_status}",
])
if 'k' in indicators:
content_parts.append(f"• KDJ: K={indicators['k']:.1f}, D={indicators['d']:.1f}")
# 添加 LLM 分析
if llm_analysis:
content_parts.extend([
"",
"---",
"",
"**AI 分析**:",
llm_analysis[:200] + "..." if len(llm_analysis) > 200 else llm_analysis
])
# 添加止损止盈建议
if stop_loss > 0 or take_profit > 0:
content_parts.extend([
"",
"---",
"",
"**风险管理**:"
])
if stop_loss > 0: if stop_loss > 0:
sl_percent = ((stop_loss - price) / price) * 100 sl_percent = ((stop_loss - price) / price) * 100
content_parts.append(f"• 建议止损: ${stop_loss:,.2f} ({sl_percent:+.1f}%)") content_parts.append(f"**止损**: ${stop_loss:,.2f} ({sl_percent:+.1f}%)")
if take_profit > 0: if take_profit > 0:
tp_percent = ((take_profit - price) / price) * 100 tp_percent = ((take_profit - price) / price) * 100
content_parts.append(f"• 建议止盈: ${take_profit:,.2f} ({tp_percent:+.1f}%)") content_parts.append(f"**止盈**: ${take_profit:,.2f} ({tp_percent:+.1f}%)")
# 添加免责声明 # 触发原因(精简)
content_parts.extend([ if reasons:
"", clean_reasons = []
"---", for reason in reasons[:2]:
"", clean = reason.replace("📊 ", "").replace("📈 ", "").replace("📉 ", "").replace("波段信号: ", "").replace("短线", "").replace("超跌反弹", "").replace("超涨回落", "")
"*⚠️ 仅供参考,不构成投资建议*" if clean and len(clean) < 20:
]) clean_reasons.append(clean)
if clean_reasons:
content_parts.append(f"**原因**: {' | '.join(clean_reasons)}")
# AI 分析
if llm_analysis:
analysis_text = llm_analysis[:100] + "..." if len(llm_analysis) > 100 else llm_analysis
content_parts.append(f"**AI**: {analysis_text}")
# 免责声明
content_parts.append("*⚠️ 仅供参考*")
content = "\n".join(content_parts) content = "\n".join(content_parts)
@ -268,14 +224,8 @@ class FeishuService:
'neutral': '震荡' 'neutral': '震荡'
} }
title = f"🔄 趋势变化 - {symbol}" title = f"🔄 {symbol} 趋势变化"
content = f"""**{symbol}** 趋势发生变化 content = f"{trend_text.get(old_trend, old_trend)}{trend_emoji.get(old_trend, '')}{trend_text.get(new_trend, new_trend)}{trend_emoji.get(new_trend, '')} | ${price:,.2f}"
**变化**: {trend_text.get(old_trend, old_trend)} {trend_emoji.get(old_trend, '')} {trend_text.get(new_trend, new_trend)} {trend_emoji.get(new_trend, '')}
**当前价格**: ${price:,.2f}
*请关注后续交易信号*"""
return await self.send_card(title, content, "orange") return await self.send_card(title, content, "orange")

View File

@ -108,89 +108,41 @@ class TelegramService:
# 等级 # 等级
grade_stars = {'A': '⭐⭐⭐', 'B': '⭐⭐', 'C': '', 'D': ''}.get(signal_grade, '') grade_stars = {'A': '⭐⭐⭐', 'B': '⭐⭐', 'C': '', 'D': ''}.get(signal_grade, '')
# 构建消息 # 构建精简消息 - 突出核心交易信息
type_short = "短线" if signal_type == 'short_term' else "波段"
lines = [ lines = [
f"{action_emoji} <b>{action_text}</b> - {symbol}", f"{action_emoji} <b>{symbol} {action_text}</b>",
f"", f"",
f"━━━━━━━━━━━━━━━━━━━━", f"📊 {type_short} | {signal_grade}{grade_stars} | {confidence}% | {trend_text}",
f"", f"💰 入场: <code>${price:,.2f}</code>",
f"{type_emoji} <b>信号类型:</b> {type_text}",
f"💡 <b>操作建议:</b> {type_hint}",
f"",
f"💰 <b>当前价格:</b> <code>${price:,.2f}</code>",
f"📊 <b>趋势方向:</b> {trend_text}",
f"🎯 <b>置信度:</b> {confidence}%",
f"⭐ <b>信号等级:</b> {signal_grade} {grade_stars}",
] ]
# 触发原因 # 止损止盈(核心点位信息)
if reasons:
lines.extend([
f"",
f"━━━━━━━━━━━━━━━━━━━━",
f"",
f"📋 <b>触发原因:</b>",
])
for reason in reasons[:5]:
# 清理 emoji 避免重复
clean_reason = reason.replace("📊 ", "").replace("📈 ", "").replace("📉 ", "")
lines.append(f"{clean_reason}")
# 技术指标
if indicators:
rsi = indicators.get('rsi', 0)
macd = indicators.get('macd', 0)
macd_signal_val = indicators.get('macd_signal', 0)
k = indicators.get('k', 0)
d = indicators.get('d', 0)
rsi_status = "超卖↑" if rsi < 30 else ("超买↓" if rsi > 70 else "中性")
macd_status = "金叉" if macd > macd_signal_val else "死叉"
lines.extend([
f"",
f"━━━━━━━━━━━━━━━━━━━━",
f"",
f"📉 <b>技术指标:</b>",
f" • RSI(14): {rsi:.1f} ({rsi_status})",
f" • MACD: {macd_status}",
])
if k > 0:
lines.append(f" • KDJ: K={k:.1f}, D={d:.1f}")
# 止损止盈
if stop_loss > 0 or take_profit > 0:
lines.extend([
f"",
f"━━━━━━━━━━━━━━━━━━━━",
f"",
f"🛡️ <b>风险管理:</b>",
])
if stop_loss > 0: if stop_loss > 0:
sl_percent = ((stop_loss - price) / price) * 100 sl_percent = ((stop_loss - price) / price) * 100
lines.append(f" 止损: <code>${stop_loss:,.2f}</code> ({sl_percent:+.1f}%)") lines.append(f"🛑 止损: <code>${stop_loss:,.2f}</code> ({sl_percent:+.1f}%)")
if take_profit > 0: if take_profit > 0:
tp_percent = ((take_profit - price) / price) * 100 tp_percent = ((take_profit - price) / price) * 100
lines.append(f" 止盈: <code>${take_profit:,.2f}</code> ({tp_percent:+.1f}%)") lines.append(f"🎯 止盈: <code>${take_profit:,.2f}</code> ({tp_percent:+.1f}%)")
# AI 分析 # 触发原因(精简)
if reasons:
clean_reasons = []
for reason in reasons[:2]:
clean = reason.replace("📊 ", "").replace("📈 ", "").replace("📉 ", "").replace("波段信号: ", "").replace("短线", "").replace("超跌反弹", "").replace("超涨回落", "")
if clean and len(clean) < 20:
clean_reasons.append(clean)
if clean_reasons:
lines.append(f"📋 {' | '.join(clean_reasons)}")
# AI 分析(如果有)
if llm_analysis: if llm_analysis:
analysis_text = llm_analysis[:150] + "..." if len(llm_analysis) > 150 else llm_analysis analysis_text = llm_analysis[:80] + "..." if len(llm_analysis) > 80 else llm_analysis
lines.extend([ lines.append(f"🤖 {analysis_text}")
f"",
f"━━━━━━━━━━━━━━━━━━━━",
f"",
f"🤖 <b>AI 分析:</b>",
f"{analysis_text}",
])
# 免责声明 # 免责声明
lines.extend([ lines.append(f"<i>⚠️ 仅供参考</i>")
f"",
f"━━━━━━━━━━━━━━━━━━━━",
f"",
f"⚠️ <i>仅供参考,不构成投资建议</i>",
])
message = "\n".join(lines) message = "\n".join(lines)
return await self.send_message(message, parse_mode="HTML") return await self.send_message(message, parse_mode="HTML")
@ -224,17 +176,8 @@ class TelegramService:
old_text = trend_text.get(old_trend, old_trend) old_text = trend_text.get(old_trend, old_trend)
new_text = trend_text.get(new_trend, new_trend) new_text = trend_text.get(new_trend, new_trend)
message = f"""🔄 <b>趋势变化 - {symbol}</b> message = f"""🔄 <b>{symbol}</b> 趋势变化
{old_text}{old_emoji} {new_text}{new_emoji} | <code>${price:,.2f}</code>"""
<b>变化:</b> {old_text} {old_emoji} {new_text} {new_emoji}
💰 <b>当前价格:</b> <code>${price:,.2f}</code>
<i>请关注后续交易信号</i>"""
return await self.send_message(message, parse_mode="HTML") return await self.send_message(message, parse_mode="HTML")