{"record":{"id":"92d810097448e08c","repo":"QuantConnect/Lean","slug":"no-holdings-were-created-for-option-contract-opti","errorCode":null,"errorMessage":"No holdings were created for option contract {option_contract.symbol}","messagePattern":"No holdings were created for option contract (.+?)","errorType":"exception","errorClass":"AssertionError","httpStatus":null,"severity":"error","filePath":"Algorithm.Python/FutureOptionShortPutOTMExpiryRegressionAlgorithm.py","lineNumber":94,"sourceCode":"\n        if not self.securities.contains_key(order_event.symbol):\n            raise AssertionError(f\"Order event Symbol not found in Securities collection: {order_event.symbol}\")\n\n        security = self.securities[order_event.symbol]\n        if security.symbol == self.es19m20:\n            raise AssertionError(f\"Expected no order events for underlying Symbol {security.symbol}\")\n\n        if security.symbol == self.expected_contract:\n            self.assert_future_option_contract_order(order_event, security)\n\n        else:\n            raise AssertionError(f\"Received order event for unknown Symbol: {order_event.symbol}\")\n\n        self.log(f\"{order_event}\")\n\n    def assert_future_option_contract_order(self, order_event: OrderEvent, option_contract: Security):\n        if order_event.direction == OrderDirection.SELL and option_contract.holdings.quantity != -1:\n            raise AssertionError(f\"No holdings were created for option contract {option_contract.symbol}\")\n\n        if order_event.direction == OrderDirection.BUY and option_contract.holdings.quantity != 0:\n            raise AssertionError(\"Expected no options holdings after closing position\")\n\n        if order_event.is_assignment:\n            raise AssertionError(f\"Assignment was not expected for {order_event.symbol}\")\n\n    def on_end_of_algorithm(self):\n        if self.portfolio.invested:\n            raise AssertionError(f\"Expected no holdings at end of algorithm, but are invested in: {', '.join([str(i.id) for i in self.portfolio.keys()])}\")\n","sourceCodeStart":76,"sourceCodeEnd":105,"githubUrl":"https://github.com/QuantConnect/Lean/blob/d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892/Algorithm.Python/FutureOptionShortPutOTMExpiryRegressionAlgorithm.py#L76-L105","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm the MarketOrder/limit order quantity submitted is exactly 1 contract.","Check that the future-option contract multiplier in the test data is 1 (or adjust the expected quantity).","Inspect prior order events for duplicate or partial fills on the same contract."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Before relying on a -1 position, assert the order quantity and multiplier\nif order_event.direction == OrderDirection.SELL and order_event.fill_quantity != -1:\n    algorithm.Debug(f'Fill quantity {order_event.fill_quantity} != -1, multiplier may differ')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Submit single-contract orders (quantity 1) in option regression tests.","Confirm the option contract multiplier in the data matches the expected position size."],"tags":["regression-test","future-options","holdings","fill"],"backgroundTag":null,"analyzedSha":"d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892","analyzedAt":"2026-08-13T13:52:21.013Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}