diff --git a/backend/app/crypto_agent/executor/hyperliquid_executor.py b/backend/app/crypto_agent/executor/hyperliquid_executor.py index deaf209..9b14f7c 100644 --- a/backend/app/crypto_agent/executor/hyperliquid_executor.py +++ b/backend/app/crypto_agent/executor/hyperliquid_executor.py @@ -94,8 +94,9 @@ class HyperliquidExecutor(BaseExecutor): } ) - # 成交后单独设置止盈止损(Hyperliquid 不支持下单时设置 TP/SL) - if order_status == 'filled' and (stop_loss or take_profit): + # 成交后设置止盈止损(Hyperliquid 不支持下单时设置 TP/SL) + # 市价单已成交直接设置;限价单(resting)也先设置,等成交后生效 + if stop_loss or take_profit: tp_sl_result = self.hyperliquid.set_tp_sl( symbol=symbol, is_long=is_buy, @@ -104,8 +105,10 @@ class HyperliquidExecutor(BaseExecutor): sl_price=stop_loss ) if not tp_sl_result.get('success'): - logger.warning(f" ⚠️ 止盈止损设置失败: {tp_sl_result.get('message')}") - result['tp_sl_warning'] = tp_sl_result.get('message') + logger.warning(f" ⚠️ 止盈止损设置失败: {tp_sl_result.get('error', tp_sl_result.get('message'))}") + result['tp_sl_warning'] = tp_sl_result.get('error', tp_sl_result.get('message')) + else: + logger.info(f" ✅ 止盈止损已设置: TP={take_profit}, SL={stop_loss}") return result