OpenBB-finance/OpenBB · error · RuntimeError
The benchmark symbol was not found in the data.
Error message
The benchmark symbol was not found in the data.
What it means
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.
Source
Thrown at openbb_platform/extensions/technical/openbb_technical/relative_rotation.py:295
):
with contextlib.suppress(Exception):
df = basemodel_to_df(convert_to_basemodel(data), index="date")
if isinstance(data, DataFrame) and not df.empty:
df = data.copy()
if "date" in df.columns:
df.set_index("date", inplace=True)
if df.empty:
raise ValueError(
"Data must be a list of Data objects or a DataFrame with a 'date' column."
)
if "symbol" in df.columns:
df = df.pivot(columns="symbol", values=target_col)
if benchmark not in df.columns:
raise RuntimeError("The benchmark symbol was not found in the data.")
benchmark_data = df.pop(benchmark).to_frame()
symbols_data = df
if len(symbols_data) <= 252 and study in ["price", "volume"]: # type: ignore
raise ValueError(
"Supplied data must be daily intervals and have more than one year of back data to calculate"
" the most recent day in the time series."
)
if study == "volatility" and len(symbols_data) <= 504: # type: ignore
raise ValueError(
"Supplied data must be daily intervals and have more than two years of back data to calculate"
" the most recent day in the time series as a volatility study."
)
self.symbols = df.columns.to_list()
self.benchmark = benchmark
self.study = studyView on GitHub (pinned to 3e071fcc2c)
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.
Example fix
# before data = obb.equity.price.historical(["AAPL", "MSFT"], provider="...") rrg = RelativeRotation(data=data, benchmark="SPY") # SPY not fetched # after data = obb.equity.price.historical(["AAPL", "MSFT", "SPY"], provider="...") rrg = RelativeRotation(data=data, benchmark="SPY")
Defensive patterns
Strategy: validation
Validate before calling
symbols_in_data = set(df["symbol"].str.upper().unique()) if "symbol" in df.columns else set(df.columns)
assert benchmark.upper() in symbols_in_data, f"benchmark {benchmark} missing; have {symbols_in_data}" Type guard
def benchmark_present(df, benchmark: str) -> bool:
if "symbol" in df.columns:
return benchmark.upper() in set(df["symbol"].str.upper().unique())
return benchmark.upper() in df.columns Try / catch
try:
rrg = RelativeRotation(data=data, benchmark=benchmark)
except RuntimeError as e:
if "benchmark symbol was not found" in str(e):
raise SystemExit(f"add {benchmark} to the fetched symbols and retry") from e
raise Prevention
- Always include the benchmark ticker in the history fetch
- Match the provider's exact benchmark symbol
- Drop rows with NaN target values before RRG
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Data must be a list of Data objects or a DataFrame with a 'd
- Supplied data must be daily intervals and have more than one
- Supplied data must be daily intervals and have more than two
- Error: No data to plot.
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/b35ea5b6c6c1c709.
Report an issue: GitHub.