{"record":{"id":"f92ae292106f9aa2","repo":"OpenBB-finance/OpenBB","slug":"error-strike-must-be-provided-if-underlying-price","errorCode":null,"errorMessage":"Error: strike must be provided if underlying_price is not available","messagePattern":"Error: strike must be provided if underlying_price is not available","errorType":"exception","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/core/openbb_core/provider/utils/options_chains_properties.py","lineNumber":712,"sourceCode":"\n        dte_estimate = self._get_nearest_expiration(days)\n\n        chains = chains[chains.expiration.astype(str) == dte_estimate]\n\n        if not hasattr(chains, \"underlying_price\") and underlying_price is None:\n            raise OpenBBError(\n                \"Error: underlying_price must be provided if underlying_price is not available\"\n            )\n        underlying_price = (\n            underlying_price\n            if underlying_price is not None\n            else chains.underlying_price.iloc[0]\n        )\n\n        force_otm = True\n\n        if strike is None and not hasattr(chains, \"underlying_price\"):\n            raise OpenBBError(\n                \"Error: strike must be provided if underlying_price is not available\"\n            )\n\n        if strike is not None:\n            force_otm = False\n\n        if strike is None:\n            strike = underlying_price\n\n        if strike is not None and strike < 0:\n            short = True\n\n        strike_price = abs(strike)  # type: ignore\n        bid_ask = \"bid\" if short else \"ask\"\n        call_price_col = self._identify_price_col(chains, \"call\", bid_ask)  # type: ignore\n        put_price_col = self._identify_price_col(chains, \"put\", bid_ask)  # type: ignore\n        call_strike_estimate = self._get_nearest_strike(\"call\", days, strike_price, call_price_col, force_otm)  # type: ignore\n        # If a strike price is supplied, the put strike is the same as the call strike.","sourceCodeStart":694,"sourceCodeEnd":730,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/core/openbb_core/provider/utils/options_chains_properties.py#L694-L730","documentation":"Raised in OptionsChainsData.strangle (options_chains_properties.py:712). When no strike was supplied, the strategy normally defaults the target strike to the underlying price; if the underlying price is unavailable (no column) AND strike is None, there is no anchor left, so it raises this sibling of error 58. If strike IS provided it sets force_otm=False and proceeds.","triggerScenarios":"Calling result.strangle(dte=30, underlying_price=None) without strike= on data lacking the underlying_price column. Providing strike= (or an underlying_price=, which satisfies the earlier check) avoids this branch.","commonSituations":"Same strangle setup as error 58: spot-free provider payloads where the caller also omitted an explicit strike; automation loops that only pass dte.","solutions":["Pass an explicit strike: res.strangle(..., strike=585)","Or supply underlying_price so the strike defaults to the spot","Or set res.last_price before calling so underlying_price is available in the dataframe"],"exampleFix":"# before\nout = res.strangle(dte=30)  # no spot column, no strike -> OpenBBError\n\n# after\nout = res.strangle(dte=30, strike=585)  # explicit strike anchor","handlingStrategy":"validation","validationCode":"has_spot = \"underlying_price\" in res.to_df().columns or res.last_price is not None\nif strike is None and not has_spot and underlying_price is None:\n    raise ValueError(\"strangle needs a strike or an underlying price\")\nout = res.strangle(dte=30, strike=strike, underlying_price=underlying_price)","typeGuard":"def has_strike_anchor(res, strike=None, underlying_price=None) -> bool:\n    return strike is not None or underlying_price is not None or \"underlying_price\" in res.to_df().columns or res.last_price is not None","tryCatchPattern":"from openbb_core.app.model.abstract.error import OpenBBError\n\ntry:\n    out = res.strangle(dte=30)\nexcept OpenBBError as e:\n    if \"strike must be provided\" in str(e) or \"underlying_price must be provided\" in str(e):\n        out = res.strangle(dte=30, strike=round_to_strike(get_spot(symbol)))\n    else:\n        raise","preventionTips":["Default to passing an explicit at-the-money strike when spot availability is unknown","Ensure last_price is set for providers that omit underlying_price","Validate strangle preconditions (strike or spot) in one shared helper before calling"],"tags":["options","strangle","strike","derivatives"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}