update
This commit is contained in:
parent
65f039235e
commit
e6d17d1e65
@ -1435,7 +1435,15 @@ class CryptoAgent:
|
|||||||
|
|
||||||
# 决策信息
|
# 决策信息
|
||||||
decision_type = decision.get('decision', 'HOLD')
|
decision_type = decision.get('decision', 'HOLD')
|
||||||
decision_reasoning = decision.get('reasoning', reason)
|
decision_reasoning = decision.get('reasoning', '')
|
||||||
|
|
||||||
|
# 如果有外部传入的 reason(订单创建失败的具体原因),优先使用
|
||||||
|
if reason:
|
||||||
|
final_reason = reason
|
||||||
|
elif decision_reasoning:
|
||||||
|
final_reason = decision_reasoning
|
||||||
|
else:
|
||||||
|
final_reason = "未知原因"
|
||||||
|
|
||||||
# 方向图标
|
# 方向图标
|
||||||
action = best_signal.get('action', 'wait')
|
action = best_signal.get('action', 'wait')
|
||||||
@ -1461,7 +1469,7 @@ class CryptoAgent:
|
|||||||
f"**当前价格**: ${current_price:,.2f}",
|
f"**当前价格**: ${current_price:,.2f}",
|
||||||
f"",
|
f"",
|
||||||
f"⚠️ **未执行原因**:",
|
f"⚠️ **未执行原因**:",
|
||||||
f"{decision_reasoning}",
|
f"{final_reason}",
|
||||||
]
|
]
|
||||||
|
|
||||||
content = "\n".join(content_parts)
|
content = "\n".join(content_parts)
|
||||||
@ -1473,7 +1481,7 @@ class CryptoAgent:
|
|||||||
message = f"{title}\n\n{content}"
|
message = f"{title}\n\n{content}"
|
||||||
await self.telegram.send_message(message)
|
await self.telegram.send_message(message)
|
||||||
|
|
||||||
logger.info(f" 📤 已发送信号未执行通知: {decision_type} - {decision_reasoning[:50]}")
|
logger.info(f" 📤 已发送信号未执行通知: {decision_type} - {final_reason[:50]}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"发送信号未执行通知失败: {e}")
|
logger.warning(f"发送信号未执行通知失败: {e}")
|
||||||
|
|||||||
@ -161,7 +161,9 @@ class PaperTradingService:
|
|||||||
# 1. 检查总订单数(持仓+挂单)是否超过最大限制
|
# 1. 检查总订单数(持仓+挂单)是否超过最大限制
|
||||||
total_orders = len(self.active_orders)
|
total_orders = len(self.active_orders)
|
||||||
if total_orders >= self.max_orders:
|
if total_orders >= self.max_orders:
|
||||||
logger.info(f"订单限制: 已达到最大订单数 {self.max_orders},跳过")
|
msg = f"已达到最大订单数限制 ({self.max_orders}个),无法创建新订单"
|
||||||
|
logger.info(f"订单限制: {msg},跳过")
|
||||||
|
result['message'] = msg
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# 2. 检查是否有接近的挂单(价格差距 < 1%)
|
# 2. 检查是否有接近的挂单(价格差距 < 1%)
|
||||||
@ -176,13 +178,17 @@ class PaperTradingService:
|
|||||||
for pending in pending_orders:
|
for pending in pending_orders:
|
||||||
price_diff = abs(pending.entry_price - entry_price) / pending.entry_price
|
price_diff = abs(pending.entry_price - entry_price) / pending.entry_price
|
||||||
if price_diff < 0.01: # 价格差距小于 1%
|
if price_diff < 0.01: # 价格差距小于 1%
|
||||||
logger.info(f"订单限制: {symbol} 已有接近的挂单 @ ${pending.entry_price:,.2f},新信号 @ ${entry_price:,.2f},跳过")
|
msg = f"已有接近的挂单 @ ${pending.entry_price:,.2f}(价格差距 {price_diff*100:.2f}%)"
|
||||||
|
logger.info(f"订单限制: {symbol} {msg},新信号 @ ${entry_price:,.2f},跳过")
|
||||||
|
result['message'] = msg
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# 获取信号等级
|
# 获取信号等级
|
||||||
grade = signal.get('signal_grade') or signal.get('grade', 'D')
|
grade = signal.get('signal_grade') or signal.get('grade', 'D')
|
||||||
if grade == 'D':
|
if grade == 'D':
|
||||||
logger.info(f"D级信号不开仓: {signal.get('symbol')}")
|
msg = "D级信号,不符合开仓条件"
|
||||||
|
logger.info(f"{msg}: {signal.get('symbol')}")
|
||||||
|
result['message'] = msg
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# === 动态仓位计算 ===
|
# === 动态仓位计算 ===
|
||||||
@ -200,7 +206,9 @@ class PaperTradingService:
|
|||||||
margin, position_value = self._calculate_dynamic_position(position_size, symbol)
|
margin, position_value = self._calculate_dynamic_position(position_size, symbol)
|
||||||
|
|
||||||
if margin <= 0:
|
if margin <= 0:
|
||||||
logger.info(f"无可用保证金: {symbol} | 当前杠杆已达上限")
|
msg = f"保证金不足或已达杠杆上限(当前杠杆已达 {self.leverage}x)"
|
||||||
|
logger.info(f"{msg}: {symbol}")
|
||||||
|
result['message'] = msg
|
||||||
return result
|
return result
|
||||||
|
|
||||||
quantity = position_value # 订单数量(以 USDT 计价)
|
quantity = position_value # 订单数量(以 USDT 计价)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user