From ead82a4554b67f26a2d6c93ef2c7bc5a3f049ed3 Mon Sep 17 00:00:00 2001
From: aaron <>
Date: Fri, 6 Feb 2026 22:03:59 +0800
Subject: [PATCH] update
---
backend/app/services/feishu_service.py | 104 ++++++---------------
backend/app/services/telegram_service.py | 113 ++++++-----------------
2 files changed, 55 insertions(+), 162 deletions(-)
diff --git a/backend/app/services/feishu_service.py b/backend/app/services/feishu_service.py
index 2ba8aab..afb80e0 100644
--- a/backend/app/services/feishu_service.py
+++ b/backend/app/services/feishu_service.py
@@ -161,83 +161,39 @@ class FeishuService:
# 等级图标
grade_icon = {'A': '⭐⭐⭐', 'B': '⭐⭐', 'C': '⭐', 'D': ''}.get(signal_grade, '')
+ type_short = "短线" if signal_type == 'short_term' else "波段"
- # 构建内容
+ # 构建精简内容 - 突出核心交易信息
content_parts = [
- f"**信号类型**: {type_text} {type_hint}",
- f"**信号等级**: {signal_grade} {grade_icon}",
- f"**当前价格**: ${price:,.2f}",
- f"**趋势方向**: {trend_text}",
- f"**置信度**: {confidence}%",
+ f"**{type_short}** | {signal_grade}{grade_icon} | {confidence}% | {trend_text}",
+ f"**入场**: ${price:,.2f}",
]
- # 添加触发原因
+ # 止损止盈(核心点位)
+ if stop_loss > 0:
+ sl_percent = ((stop_loss - price) / price) * 100
+ content_parts.append(f"**止损**: ${stop_loss:,.2f} ({sl_percent:+.1f}%)")
+ if take_profit > 0:
+ tp_percent = ((take_profit - price) / price) * 100
+ content_parts.append(f"**止盈**: ${take_profit:,.2f} ({tp_percent:+.1f}%)")
+
+ # 触发原因(精简)
if reasons:
- content_parts.extend([
- "",
- "---",
- "",
- "**触发原因**:",
- ])
- for reason in reasons[:5]: # 最多显示5个原因
- content_parts.append(f"• {reason}")
+ 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)}")
- 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 分析
+ # AI 分析
if llm_analysis:
- content_parts.extend([
- "",
- "---",
- "",
- "**AI 分析**:",
- llm_analysis[:200] + "..." if len(llm_analysis) > 200 else llm_analysis
- ])
+ analysis_text = llm_analysis[:100] + "..." if len(llm_analysis) > 100 else llm_analysis
+ content_parts.append(f"**AI**: {analysis_text}")
- # 添加止损止盈建议
- if stop_loss > 0 or take_profit > 0:
- content_parts.extend([
- "",
- "---",
- "",
- "**风险管理**:"
- ])
- if stop_loss > 0:
- sl_percent = ((stop_loss - price) / price) * 100
- content_parts.append(f"• 建议止损: ${stop_loss:,.2f} ({sl_percent:+.1f}%)")
- if take_profit > 0:
- tp_percent = ((take_profit - price) / price) * 100
- content_parts.append(f"• 建议止盈: ${take_profit:,.2f} ({tp_percent:+.1f}%)")
-
- # 添加免责声明
- content_parts.extend([
- "",
- "---",
- "",
- "*⚠️ 仅供参考,不构成投资建议*"
- ])
+ # 免责声明
+ content_parts.append("*⚠️ 仅供参考*")
content = "\n".join(content_parts)
@@ -268,14 +224,8 @@ class FeishuService:
'neutral': '震荡'
}
- title = f"🔄 趋势变化 - {symbol}"
- content = f"""**{symbol}** 趋势发生变化
-
-**变化**: {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}
-
-*请关注后续交易信号*"""
+ title = 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}"
return await self.send_card(title, content, "orange")
diff --git a/backend/app/services/telegram_service.py b/backend/app/services/telegram_service.py
index e2c7ecb..a948361 100644
--- a/backend/app/services/telegram_service.py
+++ b/backend/app/services/telegram_service.py
@@ -108,89 +108,41 @@ class TelegramService:
# 等级
grade_stars = {'A': '⭐⭐⭐', 'B': '⭐⭐', 'C': '⭐', 'D': ''}.get(signal_grade, '')
- # 构建消息
+ # 构建精简消息 - 突出核心交易信息
+ type_short = "短线" if signal_type == 'short_term' else "波段"
+
lines = [
- f"{action_emoji} {action_text} - {symbol}",
+ f"{action_emoji} {symbol} {action_text}",
f"",
- f"━━━━━━━━━━━━━━━━━━━━",
- f"",
- f"{type_emoji} 信号类型: {type_text}",
- f"💡 操作建议: {type_hint}",
- f"",
- f"💰 当前价格: ${price:,.2f}",
- f"📊 趋势方向: {trend_text}",
- f"🎯 置信度: {confidence}%",
- f"⭐ 信号等级: {signal_grade} {grade_stars}",
+ f"📊 {type_short} | {signal_grade}{grade_stars} | {confidence}% | {trend_text}",
+ f"💰 入场: ${price:,.2f}",
]
- # 触发原因
+ # 止损止盈(核心点位信息)
+ if stop_loss > 0:
+ sl_percent = ((stop_loss - price) / price) * 100
+ lines.append(f"🛑 止损: ${stop_loss:,.2f} ({sl_percent:+.1f}%)")
+ if take_profit > 0:
+ tp_percent = ((take_profit - price) / price) * 100
+ lines.append(f"🎯 止盈: ${take_profit:,.2f} ({tp_percent:+.1f}%)")
+
+ # 触发原因(精简)
if reasons:
- lines.extend([
- f"",
- f"━━━━━━━━━━━━━━━━━━━━",
- f"",
- f"📋 触发原因:",
- ])
- for reason in reasons[:5]:
- # 清理 emoji 避免重复
- clean_reason = reason.replace("📊 ", "").replace("📈 ", "").replace("📉 ", "")
- lines.append(f" • {clean_reason}")
+ 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)}")
- # 技术指标
- 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"📉 技术指标:",
- 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"🛡️ 风险管理:",
- ])
- if stop_loss > 0:
- sl_percent = ((stop_loss - price) / price) * 100
- lines.append(f" • 止损: ${stop_loss:,.2f} ({sl_percent:+.1f}%)")
- if take_profit > 0:
- tp_percent = ((take_profit - price) / price) * 100
- lines.append(f" • 止盈: ${take_profit:,.2f} ({tp_percent:+.1f}%)")
-
- # AI 分析
+ # AI 分析(如果有)
if llm_analysis:
- analysis_text = llm_analysis[:150] + "..." if len(llm_analysis) > 150 else llm_analysis
- lines.extend([
- f"",
- f"━━━━━━━━━━━━━━━━━━━━",
- f"",
- f"🤖 AI 分析:",
- f"{analysis_text}",
- ])
+ analysis_text = llm_analysis[:80] + "..." if len(llm_analysis) > 80 else llm_analysis
+ lines.append(f"🤖 {analysis_text}")
# 免责声明
- lines.extend([
- f"",
- f"━━━━━━━━━━━━━━━━━━━━",
- f"",
- f"⚠️ 仅供参考,不构成投资建议",
- ])
+ lines.append(f"⚠️ 仅供参考")
message = "\n".join(lines)
return await self.send_message(message, parse_mode="HTML")
@@ -224,17 +176,8 @@ class TelegramService:
old_text = trend_text.get(old_trend, old_trend)
new_text = trend_text.get(new_trend, new_trend)
- message = f"""🔄 趋势变化 - {symbol}
-
-━━━━━━━━━━━━━━━━━━━━
-
-变化: {old_text} {old_emoji} → {new_text} {new_emoji}
-
-💰 当前价格: ${price:,.2f}
-
-━━━━━━━━━━━━━━━━━━━━
-
-请关注后续交易信号"""
+ message = f"""🔄 {symbol} 趋势变化
+{old_text}{old_emoji} → {new_text}{new_emoji} | ${price:,.2f}"""
return await self.send_message(message, parse_mode="HTML")