diff --git a/src/simulation/simulation_trader.py b/src/simulation/simulation_trader.py index 30e9d22..af1ee0a 100644 --- a/src/simulation/simulation_trader.py +++ b/src/simulation/simulation_trader.py @@ -72,12 +72,13 @@ class SimulationTrader(BaseTrader): self.logger.info(message) # 获取策略持仓 - strategy_positions = self.position_manager.get_positions(strategy_name) + position_manager = self.get_position_manager(strategy_name) + strategy_positions = position_manager.get_positions() # 检查持仓是否足够 if ( code not in strategy_positions - or strategy_positions[code]["closeable_amount"] < amount + or strategy_positions[code].closeable_amount < amount ): message = f"模拟卖出失败 - 代码: {code}, 可用数量不足" self.logger.warning(message) @@ -88,7 +89,6 @@ class SimulationTrader(BaseTrader): self.sim_balance["cash"] += proceeds # 更新持仓管理器 - position_manager = self.get_position_manager(strategy_name) position_manager.update_position( strategy_name, code, ORDER_DIRECTION_SELL, amount )