update
This commit is contained in:
parent
b26f7713b4
commit
99d9199d8d
@ -214,9 +214,13 @@ class CryptoAgent:
|
||||
emoji = "🛑"
|
||||
status_text = "止损平仓"
|
||||
color = "red"
|
||||
elif status == 'closed_be':
|
||||
elif status == 'closed_ts':
|
||||
emoji = "📈"
|
||||
status_text = "移动止损"
|
||||
status_text = "移动止盈"
|
||||
color = "green"
|
||||
elif status == 'closed_be':
|
||||
emoji = "🔒"
|
||||
status_text = "保本止损"
|
||||
color = "orange"
|
||||
else:
|
||||
emoji = "📤"
|
||||
|
||||
@ -193,6 +193,10 @@ async def price_monitor_loop():
|
||||
emoji = "🎯"
|
||||
status_text = "止盈平仓"
|
||||
color = "green"
|
||||
elif status == 'closed_ts':
|
||||
emoji = "📈"
|
||||
status_text = "移动止盈"
|
||||
color = "green"
|
||||
elif status == 'closed_sl':
|
||||
emoji = "🛑"
|
||||
status_text = "止损平仓"
|
||||
|
||||
@ -14,6 +14,7 @@ class OrderStatus(str, Enum):
|
||||
CLOSED_TP = "closed_tp" # 止盈平仓
|
||||
CLOSED_SL = "closed_sl" # 止损平仓
|
||||
CLOSED_BE = "closed_be" # 保本止损平仓
|
||||
CLOSED_TS = "closed_ts" # 移动止盈平仓
|
||||
CLOSED_MANUAL = "closed_manual" # 手动平仓
|
||||
CANCELLED = "cancelled" # 已取消
|
||||
|
||||
|
||||
@ -587,8 +587,10 @@ class PaperTradingService:
|
||||
exit_price = order.take_profit
|
||||
elif current_price <= order.stop_loss:
|
||||
triggered = True
|
||||
# 通过标记判断是否是保本止损
|
||||
if getattr(order, 'breakeven_triggered', 0) == 1:
|
||||
# 优先级:移动止盈 > 保本止损 > 普通止损
|
||||
if getattr(order, 'trailing_stop_triggered', 0) == 1:
|
||||
new_status = OrderStatus.CLOSED_TS
|
||||
elif getattr(order, 'breakeven_triggered', 0) == 1:
|
||||
new_status = OrderStatus.CLOSED_BE
|
||||
else:
|
||||
new_status = OrderStatus.CLOSED_SL
|
||||
@ -601,8 +603,10 @@ class PaperTradingService:
|
||||
exit_price = order.take_profit
|
||||
elif current_price >= order.stop_loss:
|
||||
triggered = True
|
||||
# 通过标记判断是否是保本止损
|
||||
if getattr(order, 'breakeven_triggered', 0) == 1:
|
||||
# 优先级:移动止盈 > 保本止损 > 普通止损
|
||||
if getattr(order, 'trailing_stop_triggered', 0) == 1:
|
||||
new_status = OrderStatus.CLOSED_TS
|
||||
elif getattr(order, 'breakeven_triggered', 0) == 1:
|
||||
new_status = OrderStatus.CLOSED_BE
|
||||
else:
|
||||
new_status = OrderStatus.CLOSED_SL
|
||||
@ -670,7 +674,7 @@ class PaperTradingService:
|
||||
'signal_grade': db_order.signal_grade.value if db_order.signal_grade else None
|
||||
}
|
||||
|
||||
status_text = {"closed_tp": "止盈", "closed_sl": "止损", "closed_be": "移动止损"}.get(status.value, "平仓")
|
||||
status_text = {"closed_tp": "止盈", "closed_sl": "止损", "closed_be": "保本止损", "closed_ts": "移动止盈"}.get(status.value, "平仓")
|
||||
logger.info(f"订单{status_text}: {db_order.order_id} | {db_order.symbol} | 盈亏: {pnl_percent:+.2f}% (${pnl_amount:+.2f})")
|
||||
|
||||
return result
|
||||
@ -1075,6 +1079,7 @@ class PaperTradingService:
|
||||
OrderStatus.CLOSED_TP,
|
||||
OrderStatus.CLOSED_SL,
|
||||
OrderStatus.CLOSED_BE,
|
||||
OrderStatus.CLOSED_TS,
|
||||
OrderStatus.CLOSED_MANUAL
|
||||
])
|
||||
).all()
|
||||
@ -1354,6 +1359,7 @@ class PaperTradingService:
|
||||
OrderStatus.CLOSED_TP,
|
||||
OrderStatus.CLOSED_SL,
|
||||
OrderStatus.CLOSED_BE,
|
||||
OrderStatus.CLOSED_TS,
|
||||
OrderStatus.CLOSED_MANUAL
|
||||
])
|
||||
)
|
||||
@ -1376,6 +1382,7 @@ class PaperTradingService:
|
||||
OrderStatus.CLOSED_TP,
|
||||
OrderStatus.CLOSED_SL,
|
||||
OrderStatus.CLOSED_BE,
|
||||
OrderStatus.CLOSED_TS,
|
||||
OrderStatus.CLOSED_MANUAL
|
||||
])
|
||||
)
|
||||
@ -1516,6 +1523,7 @@ class PaperTradingService:
|
||||
OrderStatus.CLOSED_TP,
|
||||
OrderStatus.CLOSED_SL,
|
||||
OrderStatus.CLOSED_BE,
|
||||
OrderStatus.CLOSED_TS,
|
||||
OrderStatus.CLOSED_MANUAL
|
||||
])
|
||||
).all()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user