a
This commit is contained in:
parent
31b4efc284
commit
ec5cb088a9
|
|
@ -1015,7 +1015,6 @@ class PositionManager:
|
|||
trade_id = position_info.get('tradeId')
|
||||
if trade_id:
|
||||
try:
|
||||
<<<<<<< Current (Your changes)
|
||||
# 计算持仓持续时间和策略类型
|
||||
entry_time = position_info.get('entryTime')
|
||||
duration_minutes = None
|
||||
|
|
@ -1043,35 +1042,6 @@ class PositionManager:
|
|||
strategy_type=strategy_type,
|
||||
duration_minutes=duration_minutes
|
||||
)
|
||||
=======
|
||||
# 计算持仓持续时间和策略类型
|
||||
entry_time = position_info.get('entryTime')
|
||||
duration_minutes = None
|
||||
if entry_time:
|
||||
try:
|
||||
from datetime import datetime
|
||||
if isinstance(entry_time, str):
|
||||
entry_dt = datetime.strptime(entry_time, '%Y-%m-%d %H:%M:%S')
|
||||
else:
|
||||
entry_dt = entry_time
|
||||
exit_dt = datetime.now()
|
||||
duration = exit_dt - entry_dt
|
||||
duration_minutes = int(duration.total_seconds() / 60)
|
||||
except Exception as e:
|
||||
logger.debug(f"计算持仓持续时间失败: {e}")
|
||||
|
||||
strategy_type = position_info.get('strategyType', 'trend_following')
|
||||
|
||||
Trade.update_exit(
|
||||
trade_id=trade_id,
|
||||
exit_price=current_price,
|
||||
exit_reason=exit_reason,
|
||||
pnl=pnl_amount,
|
||||
pnl_percent=pnl_percent_margin,
|
||||
strategy_type=strategy_type,
|
||||
duration_minutes=duration_minutes
|
||||
)
|
||||
>>>>>>> Incoming (Background Agent changes)
|
||||
except Exception as e:
|
||||
logger.warning(f"更新止盈记录失败: {e}")
|
||||
if await self.close_position(symbol, reason=exit_reason):
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user