OpenBB-finance/OpenBB · error · ValueError

Supplied data must be daily intervals and have more than two

Error message

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.

What it means

RelativeRotation's stricter bound for study='volatility': more than 504 daily observations (two trading years) are required because the volatility study needs a longer lookback for its ratios; it raises when len(symbols_data) <= 504.

Source

Thrown at openbb_platform/extensions/technical/openbb_technical/relative_rotation.py:307

            )

        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 = study
        self.long_period = long_period
        self.short_period = short_period
        self.window = window
        self.trading_periods = trading_periods
        self.symbols_data = symbols_data  # type: ignore
        self.benchmark_data = benchmark_data  # type: ignore
        self._process_data()  # type: ignore
        self.symbols_data = df_to_basemodel(self.symbols_data.reset_index())  # type: ignore
        self.benchmark_data = df_to_basemodel(self.benchmark_data.reset_index())  # type: ignore

    def _process_data(self):
        """Process the data."""

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Fetch > 504 daily bars (e.g. limit=750 or start_date 3 years back).
  2. Confirm daily interval data.
  3. Fall back to study='price' if only ~1 year of history is available.
  4. Filter the universe to symbols with 2+ years of history before running the volatility study.

Example fix

# before
data = obb.equity.price.historical(symbols, limit=504)
RelativeRotation(data=data, benchmark="SPY", study="volatility")

# after
data = obb.equity.price.historical(symbols, limit=750)
RelativeRotation(data=data, benchmark="SPY", study="volatility")
Defensive patterns

Strategy: validation

Validate before calling

n = len(symbols_data)
assert n > 504, f"volatility RRG needs > 504 daily bars, have {n}"

Type guard

def enough_volatility_rrg_history(df) -> bool:
    return len(df) > 504

Try / catch

try:
    rrg = RelativeRotation(data=data, benchmark="SPY", study="volatility")
except ValueError as e:
    if "more than two years" in str(e):
        data = fetch_history(symbols, limit=750)
        rrg = RelativeRotation(data=data, benchmark="SPY", study="volatility")
    else:
        raise

Prevention

When it happens

Trigger: Calling RelativeRotation(study='volatility') with 504 or fewer daily rows, e.g. two years of data with holidays dropping it just below the threshold.

Common situations: Reusing a one-to-two-year fetch that sufficed for price study; provider caps limiting history; weekly/monthly series; assuming 504 is inclusive (it is not).

Related errors


AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14). Data as JSON: /api/errors/6acc8551ceb33809. Report an issue: GitHub.