{"record":{"id":"b35ea5b6c6c1c709","repo":"OpenBB-finance/OpenBB","slug":"the-benchmark-symbol-was-not-found-in-the-data","errorCode":null,"errorMessage":"The benchmark symbol was not found in the data.","messagePattern":"The benchmark symbol was not found in the data\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"openbb_platform/extensions/technical/openbb_technical/relative_rotation.py","lineNumber":295,"sourceCode":"        ):\n            with contextlib.suppress(Exception):\n                df = basemodel_to_df(convert_to_basemodel(data), index=\"date\")\n\n        if isinstance(data, DataFrame) and not df.empty:\n            df = data.copy()\n            if \"date\" in df.columns:\n                df.set_index(\"date\", inplace=True)\n\n        if df.empty:\n            raise ValueError(\n                \"Data must be a list of Data objects or a DataFrame with a 'date' column.\"\n            )\n\n        if \"symbol\" in df.columns:\n            df = df.pivot(columns=\"symbol\", values=target_col)\n\n        if benchmark not in df.columns:\n            raise RuntimeError(\"The benchmark symbol was not found in the data.\")\n\n        benchmark_data = df.pop(benchmark).to_frame()\n        symbols_data = df\n\n        if len(symbols_data) <= 252 and study in [\"price\", \"volume\"]:  # type: ignore\n            raise ValueError(\n                \"Supplied data must be daily intervals and have more than one year of back data to calculate\"\n                \" the most recent day in the time series.\"\n            )\n\n        if study == \"volatility\" and len(symbols_data) <= 504:  # type: ignore\n            raise ValueError(\n                \"Supplied data must be daily intervals and have more than two years of back data to calculate\"\n                \" the most recent day in the time series as a volatility study.\"\n            )\n        self.symbols = df.columns.to_list()\n        self.benchmark = benchmark\n        self.study = study","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/extensions/technical/openbb_technical/relative_rotation.py#L277-L313","documentation":"Raised in RelativeRotation after pivoting the data by symbol: the uppercased benchmark argument is not among the resulting columns, so there is no benchmark series to compute relative strength against.","triggerScenarios":"Calling RelativeRotation(benchmark='spy') where the data contains no 'SPY' column (benchmark not included in the fetched symbols), or where the pivot dropped it because target_col values were missing for it.","commonSituations":"Fetching history for a symbol list that omits the benchmark; benchmark ticker not supported by the provider; benchmark name casing handled (auto-uppered) but provider symbols differing (e.g. '^SPX' vs 'SPY'); NaN close values causing the pivot to drop the column.","solutions":["Include the benchmark ticker in the fetched symbol list before constructing the RRG.","Use the exact ticker symbol the provider returns (e.g. 'SPY', 'BTC/USD').","Drop rows with NaN in the target column before passing so the pivot keeps all symbols.","Verify with set(df['symbol'].unique()) that the benchmark is present."],"exampleFix":"# before\ndata = obb.equity.price.historical([\"AAPL\", \"MSFT\"], provider=\"...\")\nrrg = RelativeRotation(data=data, benchmark=\"SPY\")  # SPY not fetched\n\n# after\ndata = obb.equity.price.historical([\"AAPL\", \"MSFT\", \"SPY\"], provider=\"...\")\nrrg = RelativeRotation(data=data, benchmark=\"SPY\")","handlingStrategy":"validation","validationCode":"symbols_in_data = set(df[\"symbol\"].str.upper().unique()) if \"symbol\" in df.columns else set(df.columns)\nassert benchmark.upper() in symbols_in_data, f\"benchmark {benchmark} missing; have {symbols_in_data}\"","typeGuard":"def benchmark_present(df, benchmark: str) -> bool:\n    if \"symbol\" in df.columns:\n        return benchmark.upper() in set(df[\"symbol\"].str.upper().unique())\n    return benchmark.upper() in df.columns","tryCatchPattern":"try:\n    rrg = RelativeRotation(data=data, benchmark=benchmark)\nexcept RuntimeError as e:\n    if \"benchmark symbol was not found\" in str(e):\n        raise SystemExit(f\"add {benchmark} to the fetched symbols and retry\") from e\n    raise","preventionTips":["Always include the benchmark ticker in the history fetch","Match the provider's exact benchmark symbol","Drop rows with NaN target values before RRG"],"tags":["rrg","benchmark","relative-rotation","missing-symbol"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}