diff --git a/src/ml4t/backtest/core/execution_engine.py b/src/ml4t/backtest/core/execution_engine.py index 6da75ef..8ce1cef 100644 --- a/src/ml4t/backtest/core/execution_engine.py +++ b/src/ml4t/backtest/core/execution_engine.py @@ -496,10 +496,14 @@ def _process_single_order(self, order, use_open: bool, filled_orders: list) -> N # Permissive mode: silently skip unaffordable orders for this cycle # by cancelling them instead of keeping them pending forever. order.status = OrderStatus.CANCELLED - elif broker.partial_fills_allowed and "insufficient" in rejection_reason.lower() or ( - order.rebalance_id is not None - and broker.share_type.value == "integer" + elif ( + broker.partial_fills_allowed and "insufficient" in rejection_reason.lower() + or ( + order.rebalance_id is not None + and broker.share_type.value == "integer" + and "insufficient" in rejection_reason.lower() + ) ): if fill.try_partial_fill(order, fill_price): filled_orders.append(order)