This commit is contained in:
aaron 2026-03-30 20:46:28 +08:00
parent d0be36869e
commit ac6a8d4388
2 changed files with 16 additions and 3 deletions

View File

@ -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))

View File

@ -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}"