This commit is contained in:
aaron 2026-02-21 19:29:08 +08:00
parent a4bb3856ff
commit d45dbd044c

View File

@ -130,6 +130,42 @@ async def price_monitor_loop():
status = result.get('status', '') status = result.get('status', '')
event_type = result.get('event_type', 'order_closed') event_type = result.get('event_type', 'order_closed')
# 处理止损移动事件
if event_type == 'stop_loss_moved':
move_type = result.get('move_type', '')
side_text = "做多" if result.get('side') == 'long' else "做空"
pnl = result.get('current_pnl_percent', 0)
if move_type == 'trailing_first':
message = f"""📈 移动止损已激活
交易对: {result.get('symbol')}
方向: {side_text}
当前盈利: {pnl:+.2f}%
新止损价: ${result.get('new_stop_loss', 0):,.2f}
💰 锁定利润让利润奔跑"""
elif move_type == 'trailing_update':
message = f"""📊 止损已上移
交易对: {result.get('symbol')}
方向: {side_text}
当前盈利: {pnl:+.2f}%
新止损价: ${result.get('new_stop_loss', 0):,.2f}
🎯 继续锁定更多利润"""
elif move_type == 'breakeven':
message = f"""🔒 保本止损已触发
交易对: {result.get('symbol')}
方向: {side_text}
当前盈利: {pnl:+.2f}%
止损移至: ${result.get('new_stop_loss', 0):,.2f} (保本价)"""
# 发送通知
await feishu.send_text(message)
await telegram.send_message(message)
logger.info(f"后台监控触发止损移动: {result.get('order_id')} | {symbol}")
continue
# 处理挂单成交事件 # 处理挂单成交事件
if event_type == 'order_filled': if event_type == 'order_filled':
side_text = "做多" if result.get('side') == 'long' else "做空" side_text = "做多" if result.get('side') == 'long' else "做空"