{"record":{"id":"81c3598372f4ac8a","repo":"QuantConnect/Lean","slug":"regression-test-failed-current-ask-price-was-not","errorCode":null,"errorMessage":"Regression test failed: current ask price was not loaded from NWSA backtest file and is not $1.1","messagePattern":"Regression test failed: current ask price was not loaded from NWSA backtest file and is not \\$1\\.1","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"Algorithm.Python/OptionRenameRegressionAlgorithm.py","lineNumber":56,"sourceCode":"        if not self.portfolio.invested: \n            for kvp in slice.option_chains:\n                chain = kvp.value\n                if self.time.day == 28 and self.time.hour > 9 and self.time.minute > 0:\n    \n                    contracts = [i for i in sorted(chain, key=lambda x:x.expiry) \n                                         if i.right ==  OptionRight.CALL and \n                                            i.strike == 33 and\n                                            i.expiry.date() == datetime(2013,8,17).date()]\n                    if contracts:\n                        # Buying option\n                        contract = contracts[0]\n                        self.buy(contract.symbol, 1)\n                        # Buy the undelying stock\n                        underlying_symbol = contract.symbol.underlying\n                        self.buy (underlying_symbol, 100)\n                        # check\n                        if float(contract.ask_price) != 1.1:\n                            raise ValueError(\"Regression test failed: current ask price was not loaded from NWSA backtest file and is not $1.1\")\n        elif self.time.day == 2 and self.time.hour > 14 and self.time.minute > 0:\n            for kvp in slice.option_chains:\n                chain = kvp.value\n                self.liquidate()\n                contracts = [i for i in sorted(chain, key=lambda x:x.expiry) \n                                        if i.right ==  OptionRight.CALL and \n                                           i.strike == 33 and\n                                           i.expiry.date() == datetime(2013,8,17).date()]\n            if contracts:\n                contract = contracts[0]\n                self.log(\"Bid Price\" + str(contract.bid_price))\n                if float(contract.bid_price) != 0.05:\n                    raise ValueError(\"Regression test failed: current bid price was not loaded from FOXA file and is not $0.05\")\n\n    def on_order_event(self, order_event):\n        self.log(str(order_event))\n","sourceCodeStart":38,"sourceCodeEnd":73,"githubUrl":"https://github.com/QuantConnect/Lean/blob/d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892/Algorithm.Python/OptionRenameRegressionAlgorithm.py#L38-L73","documentation":"This is a regression assertion in Lean's OptionRenameRegressionAlgorithm that verifies historical option quote data survived a corporate-action/symbol rename (the algorithm subscribes to TFCFA, which historically maps through NWSA, the old News Corp ticker). It checks that contract.ask_price for a specific CALL (strike 33, expiry 2013-08-17) equals exactly 1.1, proving the rename-mapped factor file and the backtest data file loaded with the right ask price. A failure means the data mapping, the regression data zip, or the symbol-mapping resolver returned a different ask price than the recorded golden value.","triggerScenarios":"Running the rename regression on 2013-06-28 after 09:00 when the option chain for TFCFA is available, selecting the CALL strike 33 / 2013-08-17 contract, and reading contract.ask_price when it is not float-equal to 1.1. Happens when the regression data package was regenerated, the symbol mapping changed, or a factor/rename file was edited.","commonSituations":"Updating the Lean regression data zips; changing the Symbol / SecurityIdentifier mapping logic; adding or editing a map file for NWSA/TFCFA/FOXA; floating the ask price through a normalization step that introduced rounding so 1.1 became 1.1000001.","solutions":["Confirm the regression data zip for this algorithm is unchanged; if data was regenerated, update the golden expected value (1.1) to the new correct ask price.","Inspect the map/factor files under Lean/Data for TFCFA/NWSA to ensure the rename mapping resolves to the original NWSA backtest file.","Replace the brittle exact float equality (== 1.1) with a tolerance check (abs(ask - 1.1) < 1e-6) if the value is correct but floating-point representation changed.","Verify the SecurityIdentifier mapping resolver returns the same SID for the contract so the same quote row is loaded."],"exampleFix":"// before\nif float(contract.ask_price) != 1.1:\n    raise ValueError('...not $1.1')\n// after\nif abs(float(contract.ask_price) - 1.1) > 1e-6:\n    raise ValueError(f'ask price {contract.ask_price} != 1.1 after rename mapping')","handlingStrategy":"validation","validationCode":"# Use a tolerance instead of exact float equality for loaded quote prices\nASK_GOLDEN = 1.1\nif abs(float(contract.ask_price) - ASK_GOLDEN) > 1e-6:\n    raise ValueError(f'NWSA ask {contract.ask_price} != {ASK_GOLDEN}')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never compare floats with == for prices loaded from data; use a tolerance.","Pin regression data zips so symbol-rename golden values stay stable.","When regenerating data, update golden constants in lockstep.","Validate map/factor files resolve the renamed ticker to the expected historical file."],"tags":["options","symbol-rename","regression-test","quantconnect","data-mapping"],"backgroundTag":null,"analyzedSha":"d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892","analyzedAt":"2026-08-13T13:52:21.013Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}