QuantConnect/Lean · error · AssertionError

No holdings were created for option contract {option_contrac

Error message

No holdings were created for option contract {option_contract.symbol}

What it means

In assert_future_option_contract_order, a SELL fill on the option contract must create a -1 short position (this algorithm shorts one put). If holdings.quantity is not exactly -1 after the sell fill, the position sizing/lot multiplier is wrong and the assertion fails.

Source

Thrown at Algorithm.Python/FutureOptionShortPutOTMExpiryRegressionAlgorithm.py:94

        if not self.securities.contains_key(order_event.symbol):
            raise AssertionError(f"Order event Symbol not found in Securities collection: {order_event.symbol}")

        security = self.securities[order_event.symbol]
        if security.symbol == self.es19m20:
            raise AssertionError(f"Expected no order events for underlying Symbol {security.symbol}")

        if security.symbol == self.expected_contract:
            self.assert_future_option_contract_order(order_event, security)

        else:
            raise AssertionError(f"Received order event for unknown Symbol: {order_event.symbol}")

        self.log(f"{order_event}")

    def assert_future_option_contract_order(self, order_event: OrderEvent, option_contract: Security):
        if order_event.direction == OrderDirection.SELL and option_contract.holdings.quantity != -1:
            raise AssertionError(f"No holdings were created for option contract {option_contract.symbol}")

        if order_event.direction == OrderDirection.BUY and option_contract.holdings.quantity != 0:
            raise AssertionError("Expected no options holdings after closing position")

        if order_event.is_assignment:
            raise AssertionError(f"Assignment was not expected for {order_event.symbol}")

    def on_end_of_algorithm(self):
        if self.portfolio.invested:
            raise AssertionError(f"Expected no holdings at end of algorithm, but are invested in: {', '.join([str(i.id) for i in self.portfolio.keys()])}")

View on GitHub (pinned to d2c3659f87)

Solutions

  1. Confirm the MarketOrder/limit order quantity submitted is exactly 1 contract.
  2. Check that the future-option contract multiplier in the test data is 1 (or adjust the expected quantity).
  3. Inspect prior order events for duplicate or partial fills on the same contract.
Defensive patterns

Strategy: validation

Validate before calling

# Before relying on a -1 position, assert the order quantity and multiplier
if order_event.direction == OrderDirection.SELL and order_event.fill_quantity != -1:
    algorithm.Debug(f'Fill quantity {order_event.fill_quantity} != -1, multiplier may differ')

Prevention

When it happens

Trigger: An OrderEvent with direction == OrderDirection.SELL fills, but option_contract.holdings.quantity != -1 (e.g., 0, -2, or some other magnitude), meaning the fill didn't produce the expected single-contract short.

Common situations: Option contract multiplier changed, order quantity was set to a value other than 1, a partial fill left a non-unit position, or a duplicate fill doubled the position.

Related errors


AI-assisted analysis of QuantConnect/Lean@d2c3659f87 (2026-08-13). Data as JSON: /api/errors/92d810097448e08c. Report an issue: GitHub.