a
This commit is contained in:
parent
31b4efc284
commit
ec5cb088a9
|
|
@ -1015,35 +1015,6 @@ class PositionManager:
|
||||||
trade_id = position_info.get('tradeId')
|
trade_id = position_info.get('tradeId')
|
||||||
if trade_id:
|
if trade_id:
|
||||||
try:
|
try:
|
||||||
<<<<<<< Current (Your changes)
|
|
||||||
# 计算持仓持续时间和策略类型
|
|
||||||
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
|
|
||||||
)
|
|
||||||
=======
|
|
||||||
# 计算持仓持续时间和策略类型
|
# 计算持仓持续时间和策略类型
|
||||||
entry_time = position_info.get('entryTime')
|
entry_time = position_info.get('entryTime')
|
||||||
duration_minutes = None
|
duration_minutes = None
|
||||||
|
|
@ -1071,7 +1042,6 @@ class PositionManager:
|
||||||
strategy_type=strategy_type,
|
strategy_type=strategy_type,
|
||||||
duration_minutes=duration_minutes
|
duration_minutes=duration_minutes
|
||||||
)
|
)
|
||||||
>>>>>>> Incoming (Background Agent changes)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"更新止盈记录失败: {e}")
|
logger.warning(f"更新止盈记录失败: {e}")
|
||||||
if await self.close_position(symbol, reason=exit_reason):
|
if await self.close_position(symbol, reason=exit_reason):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user