This commit is contained in:
aaron 2026-04-05 23:52:19 +08:00
parent de75b0419b
commit 582b8e1f02
2 changed files with 11 additions and 28 deletions

View File

@ -1144,9 +1144,7 @@ class CryptoAgent:
if decision_type == 'HOLD':
hold_reason = decision.get('reason', decision.get('reasoning', '观望'))
logger.info(f"\n📊 交易决策: {hold_reason}")
await self._notify_signal_not_executed(
market_signal, decision, current_price, reason=f"[模拟盘] {hold_reason}", prefix="[模拟盘]"
)
# 仅记录日志,不发飞书通知(避免消息过多)
return
logger.info(f"\n📊 【执行交易】")
@ -1172,7 +1170,7 @@ class CryptoAgent:
else:
error = result.get('error', result.get('message', '未知错误'))
logger.error(f" ❌ 交易失败: {error}")
await self._notify_execution_failure(market_signal, decision, error, prefix="[模拟盘]")
# 仅记录日志,不发飞书通知(避免消息过多)
# 执行平仓
elif decision_type == 'CLOSE':
@ -2704,9 +2702,7 @@ class CryptoAgent:
if decision_type == 'HOLD':
hold_reason = decision.get('reason', decision.get('reasoning', '观望'))
logger.info(f" Bitget 决策: {hold_reason}")
await self._notify_signal_not_executed(
market_signal, decision, current_price, reason=f"[Bitget] {hold_reason}", prefix="[Bitget]"
)
# 仅记录日志,不发飞书通知(避免消息过多)
return
# 使用执行器
@ -3046,9 +3042,7 @@ class CryptoAgent:
if decision_type == 'HOLD':
hold_reason = decision.get('reason', decision.get('reasoning', '观望'))
logger.info(f" Hyperliquid 决策: {hold_reason}")
await self._notify_signal_not_executed(
market_signal, decision, current_price, reason=f"[Hyperliquid] {hold_reason}", prefix="[Hyperliquid]"
)
# 仅记录日志,不发飞书通知(避免消息过多)
return
# 使用执行器

View File

@ -71,12 +71,13 @@ class PaperTradingExecutor(BaseExecutor):
current_price=current_price
)
if result.get('success'):
order = result.get('order')
# create_order_from_signal 返回 {'order': ..., 'cancelled_orders': []}
# 通过 order 是否存在判断成功
order = result.get('order')
if order:
success_result = {
'success': True,
'order_id': order.order_id if order else None,
'order_id': order.order_id,
'order_type': order_type,
'entry_price': entry_price if order_type == 'limit' else current_price,
'margin': adjusted_margin,
@ -106,26 +107,14 @@ class PaperTradingExecutor(BaseExecutor):
'message': result.get('message', '下单失败')
}
# 发送失败通知
await self.send_execution_notification(
operation='OPEN',
symbol=symbol,
result=fail_result
)
# 仅记录日志,不发飞书通知(避免消息过多)
logger.warning(f"[模拟盘] 开仓未成功: {symbol} - {fail_result['message']}")
return fail_result
except Exception as e:
logger.error(f"[模拟盘] 开仓失败: {e}")
error_result = {'success': False, 'error': str(e)}
# 发送失败通知
await self.send_execution_notification(
operation='OPEN',
symbol=decision.get('symbol', ''),
result=error_result
)
return error_result
async def execute_close(self, decision: Dict[str, Any],