fix sell in simulation trader
This commit is contained in:
parent
675ffb46a6
commit
ba943ce9c6
@ -72,12 +72,13 @@ class SimulationTrader(BaseTrader):
|
|||||||
self.logger.info(message)
|
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 (
|
if (
|
||||||
code not in strategy_positions
|
code not in strategy_positions
|
||||||
or strategy_positions[code]["closeable_amount"] < amount
|
or strategy_positions[code].closeable_amount < amount
|
||||||
):
|
):
|
||||||
message = f"模拟卖出失败 - 代码: {code}, 可用数量不足"
|
message = f"模拟卖出失败 - 代码: {code}, 可用数量不足"
|
||||||
self.logger.warning(message)
|
self.logger.warning(message)
|
||||||
@ -88,7 +89,6 @@ class SimulationTrader(BaseTrader):
|
|||||||
self.sim_balance["cash"] += proceeds
|
self.sim_balance["cash"] += proceeds
|
||||||
|
|
||||||
# 更新持仓管理器
|
# 更新持仓管理器
|
||||||
position_manager = self.get_position_manager(strategy_name)
|
|
||||||
position_manager.update_position(
|
position_manager.update_position(
|
||||||
strategy_name, code, ORDER_DIRECTION_SELL, amount
|
strategy_name, code, ORDER_DIRECTION_SELL, amount
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user