From ac6a8d4388e095a5574001dfe1d66dc14248328e Mon Sep 17 00:00:00 2001 From: aaron <> Date: Mon, 30 Mar 2026 20:46:28 +0800 Subject: [PATCH] 1 --- backend/app/crypto_agent/crypto_agent.py | 17 +++++++++++++++-- .../app/crypto_agent/executor/base_executor.py | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/backend/app/crypto_agent/crypto_agent.py b/backend/app/crypto_agent/crypto_agent.py index f061be0..ce1ed07 100644 --- a/backend/app/crypto_agent/crypto_agent.py +++ b/backend/app/crypto_agent/crypto_agent.py @@ -3891,9 +3891,16 @@ class CryptoAgent: # 执行操作 if action == 'TAKE_PROFIT': # 达到目标盈利,平仓 + normalized_symbol = self._normalize_symbol(symbol) + # 从持仓列表中找到对应的 order_id + close_order_ids = [ + p.get('order_id') for p in positions + if self._normalize_symbol(p.get('symbol', '')) == normalized_symbol and p.get('order_id') + ] decision = { 'decision': 'CLOSE', - 'symbol': self._normalize_symbol(symbol), + 'symbol': normalized_symbol, + 'orders_to_close': close_order_ids, 'reason': reason } result = await executor.execute_close(decision, current_prices.get(symbol, 0)) @@ -3906,9 +3913,15 @@ class CryptoAgent: elif action == 'TIME_EXIT': # 持仓超时,平仓 + normalized_symbol = self._normalize_symbol(symbol) + close_order_ids = [ + p.get('order_id') for p in positions + if self._normalize_symbol(p.get('symbol', '')) == normalized_symbol and p.get('order_id') + ] decision = { 'decision': 'CLOSE', - 'symbol': self._normalize_symbol(symbol), + 'symbol': normalized_symbol, + 'orders_to_close': close_order_ids, 'reason': reason } result = await executor.execute_close(decision, current_prices.get(symbol, 0)) diff --git a/backend/app/crypto_agent/executor/base_executor.py b/backend/app/crypto_agent/executor/base_executor.py index db38adb..e2c4f87 100644 --- a/backend/app/crypto_agent/executor/base_executor.py +++ b/backend/app/crypto_agent/executor/base_executor.py @@ -556,7 +556,7 @@ class BaseExecutor(ABC): details: Optional[Dict[str, Any]] = None): """发送平仓通知""" success = result.get('success', False) - error_msg = result.get('error', '') + error_msg = result.get('error', result.get('message', '')) if success: title = f"✅ [{self.platform_name}] 平仓成功 - {symbol}"