fix bug
This commit is contained in:
parent
265e9d39c8
commit
ed8d6be496
@ -984,12 +984,26 @@ class CryptoAgent:
|
||||
position_value = margin * leverage if isinstance(margin, (int, float)) else 'N/A'
|
||||
position_value_display = f"${position_value:,.2f}" if isinstance(position_value, (int, float)) else "N/A"
|
||||
|
||||
# 从市场信号中获取入场方式
|
||||
best_signal = self._get_best_signal_from_market(market_signal)
|
||||
entry_type = best_signal.get('entry_type', 'market') if best_signal else 'market'
|
||||
entry_type_text = '现价单' if entry_type == 'market' else '挂单等待'
|
||||
entry_type_icon = '⚡' if entry_type == 'market' else '⏳'
|
||||
|
||||
# 根据入场方式显示不同的价格信息
|
||||
if entry_type == 'market':
|
||||
price_display = f"💵 **入场价**: ${current_price:,.2f} (现价)"
|
||||
else:
|
||||
entry_price = best_signal.get('entry_zone', current_price) if best_signal else current_price
|
||||
price_display = f"💵 **挂单价**: ${entry_price:,.2f} (等待)"
|
||||
|
||||
content_parts = [
|
||||
f"{action_icon} **操作**: {decision_text} ({action_text})",
|
||||
f"{entry_type_icon} **入场方式**: {entry_type_text}",
|
||||
f"{position_display.replace(' ', ': **')} | 📈 信心度: **{confidence}%**",
|
||||
f"",
|
||||
f"💰 **持仓价值**: {position_value_display}",
|
||||
f"💵 **入场价**: ${current_price:,.2f}",
|
||||
price_display,
|
||||
]
|
||||
|
||||
if stop_loss:
|
||||
@ -997,14 +1011,12 @@ class CryptoAgent:
|
||||
if take_profit:
|
||||
content_parts.append(f"🎯 **止盈价**: ${take_profit}")
|
||||
|
||||
# 简洁的决策理由和风险分析(各1句话)
|
||||
content_parts.append(f"")
|
||||
content_parts.append(f"📝 **决策理由**:")
|
||||
content_parts.append(f"{reasoning}")
|
||||
content_parts.append(f"📝 **决策**: {reasoning}")
|
||||
|
||||
if risk_analysis:
|
||||
content_parts.append(f"")
|
||||
content_parts.append(f"⚠️ **风险分析**:")
|
||||
content_parts.append(f"{risk_analysis}")
|
||||
content_parts.append(f"⚠️ **风险**: {risk_analysis}")
|
||||
|
||||
content_parts.append(f"")
|
||||
content_parts.append(f"💼 模拟交易已执行")
|
||||
|
||||
@ -136,8 +136,8 @@ class TradingDecisionMaker:
|
||||
"position_size": "heavy/medium/light",
|
||||
"quantity": 1200,
|
||||
"confidence": 0-100,
|
||||
"reasoning": "决策理由",
|
||||
"risk_analysis": "风险分析",
|
||||
"reasoning": "简洁的决策理由(1句话,15字以内)",
|
||||
"risk_analysis": "核心风险点(1句话,15字以内)",
|
||||
"stop_loss": 65500,
|
||||
"take_profit": 67500,
|
||||
"notes": "其他说明"
|
||||
@ -151,12 +151,20 @@ class TradingDecisionMaker:
|
||||
- **position_size** 和 **quantity** 必须匹配(heavy 对应最大保证金金额)
|
||||
- **入场方式由市场信号决定**,你只需要根据市场信号的 `entry_type` 来执行交易
|
||||
|
||||
## 输出简洁性要求(重要!)
|
||||
- **reasoning(决策理由)**:用1句话说清楚决策原因,不超过15个字
|
||||
- ❌ 错误示例:"由于市场信号显示强劲的上升趋势,且当前可用杠杆空间充足,因此决定开仓做多"
|
||||
- ✅ 正确示例:"A级信号,上升趋势明确,空间充足"
|
||||
- **risk_analysis(风险分析)**:用1句话指出核心风险,不超过15个字
|
||||
- ❌ 错误示例:"需要注意市场波动性增加可能带来的潜在亏损风险,同时关注止损位的设置"
|
||||
- ✅ 正确示例:"关注波动风险,止损设好"
|
||||
|
||||
## 注意事项
|
||||
1. **安全第一**:宁可错过机会,也不要冒过大风险
|
||||
2. **遵守杠杆限制**:总杠杆永远不超过 20 倍
|
||||
3. **理性决策**:不要被 FOMO 情绪左右
|
||||
4. **灵活应变**:根据市场变化调整策略
|
||||
5. **记录决策**:清晰记录决策理由,便于复盘
|
||||
5. **简洁输出**:决策理由和风险分析必须简明扼要
|
||||
|
||||
记住:你是交易执行者,不是市场分析师。市场分析已经完成了,你只需要根据分析结果和当前状态做出理性的交易决策!
|
||||
"""
|
||||
|
||||
@ -189,21 +189,30 @@ async def price_monitor_loop():
|
||||
# 处理挂单成交事件
|
||||
if event_type == 'order_filled':
|
||||
side_text = "做多" if result.get('side') == 'long' else "做空"
|
||||
side_icon = '🟢' if result.get('side') == 'long' else '🔴'
|
||||
grade = result.get('signal_grade', 'N/A')
|
||||
|
||||
message = f"""✅ 挂单成交
|
||||
title = f"✅ 挂单成交 - {result.get('symbol')}"
|
||||
|
||||
交易对: {result.get('symbol')}
|
||||
方向: {side_text}
|
||||
等级: {grade}
|
||||
挂单价: ${result.get('entry_price', 0):,.2f}
|
||||
成交价: ${result.get('filled_price', 0):,.2f}
|
||||
仓位: ${result.get('quantity', 0):,.0f}
|
||||
止损: ${result.get('stop_loss', 0):,.2f}
|
||||
止盈: ${result.get('take_profit', 0):,.2f}"""
|
||||
content_parts = [
|
||||
f"{side_icon} **方向**: {side_text}",
|
||||
f"",
|
||||
f"⭐ **信号等级**: {grade}",
|
||||
f"",
|
||||
f"💰 **挂单价**: ${result.get('entry_price', 0):,.2f}",
|
||||
f"🎯 **成交价**: ${result.get('filled_price', 0):,.2f}",
|
||||
f"📊 **持仓价值**: ${result.get('quantity', 0):,.0f}",
|
||||
f"",
|
||||
f"🛑 **止损价**: ${result.get('stop_loss', 0):,.2f}",
|
||||
f"🎯 **止盈价**: ${result.get('take_profit', 0):,.2f}"
|
||||
]
|
||||
|
||||
content = "\n".join(content_parts)
|
||||
|
||||
# 发送通知
|
||||
await feishu.send_text(message)
|
||||
await feishu.send_card(title, content, "blue")
|
||||
if telegram:
|
||||
message = f"{title}\n\n{content}"
|
||||
await telegram.send_message(message)
|
||||
logger.info(f"后台监控触发挂单成交: {result.get('order_id')} | {symbol}")
|
||||
continue
|
||||
|
||||
Loading…
Reference in New Issue
Block a user