{"record":{"id":"63dd702d04487718","repo":"OpenBB-finance/OpenBB","slug":"expiration-field-not-found-in-the-data","errorCode":null,"errorMessage":"Expiration field not found in the data.","messagePattern":"Expiration field not found in the data\\.","errorType":"exception","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/extensions/derivatives/openbb_derivatives/derivatives_views.py","lineNumber":102,"sourceCode":"        if data:\n            if isinstance(data, DataFrame) and not data.empty:  # noqa: SIM108\n                df = data\n            elif isinstance(data, (list, Data)):\n                df = DataFrame([d.model_dump(exclude_none=True, exclude_unset=True) for d in data])  # type: ignore\n            else:\n                pass\n        else:\n            df = DataFrame(\n                [d.model_dump(exclude_none=True, exclude_unset=True) for d in kwargs[\"obbject_item\"]]  # type: ignore\n                if isinstance(kwargs.get(\"obbject_item\"), list)\n                else kwargs[\"obbject_item\"].model_dump(exclude_none=True, exclude_unset=True)  # type: ignore\n            )\n\n        if df.empty:\n            raise OpenBBError(\"Error: No data to plot.\")\n\n        if \"expiration\" not in df.columns:\n            raise OpenBBError(\"Expiration field not found in the data.\")\n\n        if \"price\" not in df.columns:\n            raise ValueError(\"Price field not found in the data.\")\n\n        provider = kwargs.get(\"provider\", \"\")\n\n        if provider != \"deribit\":\n            df[\"expiration\"] = df[\"expiration\"].apply(to_datetime).dt.strftime(\"%b-%Y\")\n\n        if (\n            provider == \"cboe\"\n            and \"date\" in df.columns\n            and len(df[\"date\"].unique()) > 1\n            and \"symbol\" in df.columns\n        ):\n            df[\"expiration\"] = df.symbol\n\n        # Use a complete list of expirations to categorize the x-axis across all dates.","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/extensions/derivatives/openbb_derivatives/derivatives_views.py#L84-L120","documentation":"Raised by the derivatives futures curve charting view when the assembled DataFrame has no 'expiration' column. The curve plot maps each expiration to a point on the x-axis, so the field is mandatory regardless of provider. It fires after the empty-check, on any non-empty frame missing that column.","triggerScenarios":"Calling the futures curve chart with data= (a custom DataFrame or list of Data models) whose fields don't include 'expiration' - e.g. feeding a futures historical (price-by-date) payload instead of a curve payload, or a model with expiration excluded by exclude_none/exclude_unset because all values were None.","commonSituations":"Passing the wrong endpoint's results to the curve chart; Data models serialized with exclude_none dropping a None expiration; column renamed in user-side preprocessing (e.g. 'expiry').","solutions":["Feed curve data, not historical data: use obb.derivatives.futures.curve results.","If supplying custom data, ensure each record has an 'expiration' field and rename 'expiry'/'maturity' to 'expiration'.","Avoid dumping with exclude_unset when expiration may be unset; materialize the column first.","Verify: 'expiration' in df.columns before calling to_chart/show."],"exampleFix":"# before\ndf = my_expiry_frame.rename(columns={'maturity': 'expiration'}) if ... else my_expiry_frame  # missing column\n\n# after\ndf = my_expiry_frame.rename(columns={'maturity': 'expiration'})\nassert 'expiration' in df.columns and 'price' in df.columns\nfig, _ = obb.derivatives.futures.curve charting with data=df","handlingStrategy":"validation","validationCode":"df = <your frame>\nif 'expiration' not in df.columns:\n    df = df.rename(columns={'expiry': 'expiration', 'maturity': 'expiration'})\nassert 'expiration' in df.columns, 'curve chart requires expiration'","typeGuard":"def curve_ready(df) -> bool:\n    return not df.empty and {'expiration', 'price'} <= set(df.columns)","tryCatchPattern":null,"preventionTips":["Pass curve-shaped payloads (expiration + price) to the curve chart, never historical price frames.","Rename provider-native expiry columns to 'expiration' up front."],"tags":["openbb","charting","futures","schema"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}