OpenBB-finance/OpenBB · error · Exception

Failed to convert results to chart. Ensure the provided data

Error message

Failed to convert results to chart. Ensure the provided data is a valid time series. {e}

What it means

to_chart (core/to_chart.py:66) is the bridge that turns router output into a candle/TA chart; its outer `except Exception` re-raises a bare Exception("Failed to convert results to chart. Ensure the provided data is a valid time series. {e}") chaining the original. The inner cause is almost always data-shape related: a DatetimeIndex is missing/unsorted, the frame lacks OHLC columns, or values are non-numeric — i.e. the input is not a valid time series for candlestick plotting.

Source

Thrown at openbb_platform/obbject_extensions/charting/openbb_charting/core/to_chart.py:66

    # pylint: disable=import-outside-toplevel
    from openbb_charting.core.plotly_ta.ta_class import PlotlyTA

    try:
        ta = PlotlyTA()
        fig = ta.plot(  # type: ignore
            df_stock=data,
            indicators=indicators,
            symbol=symbol,
            candles=candles,
            volume=volume,
            prepost=prepost,
            volume_ticks_x=volume_ticks_x,
        )
        content = fig.show(external=True).to_plotly_json()

        return fig, content
    except Exception as e:
        raise Exception(
            f"Failed to convert results to chart. Ensure the provided data is a valid time series. {e}"
        ) from e

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Inspect the chained __cause__ for the precise failure (KeyError, ValueError from plotly, pandas errors).
  2. Normalize before charting: ensure a DatetimeIndex, numeric OHLC columns, and non-empty data (raise/skip when empty).
  3. Confirm the underlying router command actually returned rows — an EmptyDataError upstream sometimes surfaces here as an empty frame.
  4. If the data isn't a time series, render it as a table or bar chart instead of candles.

Example fix

# before
result = obbject.equity.price.historical(symbol="AAPL", provider="xyz")
result.charting()  # Exception: Failed to convert results to chart...

# after
df = result.to_df()
if not df.empty:
    df.index = pd.to_datetime(df.index)
    df[["open", "high", "low", "close"]] = df[["open", "high", "low", "close"]].apply(pd.to_numeric, errors="coerce")
    obbject.charting.to_chart(data=df, symbol="AAPL", candles=True)
Defensive patterns

Strategy: try-catch

Validate before calling

def chartable_timeseries(df) -> bool:
    return (
        not df.empty
        and isinstance(df.index, pd.DatetimeIndex)
        and bool(set(map(str.lower, df.columns)) & {"close", "adj close", "adj_close"})
    )

if chartable_timeseries(result.to_df()):
    obbject.charting.to_chart(data=result.to_df(), symbol="AAPL")

Type guard

def is_valid_timeseries(df: pd.DataFrame) -> bool:
    return (not df.empty) and isinstance(df.index, pd.DatetimeIndex) and df.index.is_monotonic_increasing

Try / catch

try:
    fig, content = obbject.charting.to_chart(data=df, symbol=symbol)
except Exception as e:
    logger.error("chart conversion failed, cause=%s", e.__cause__)
    # fall back to tabular output
    print(df.to_string())

Prevention

When it happens

Trigger: Passing a DataFrame without a DatetimeIndex (or with unparseable dates), an empty result, non-numeric price columns, or a Pydantic-object list that was never converted to a DataFrame, into obbject.charting.to_chart / the charting extension's .charting() accessor.

Common situations: Calling .charting() on a command whose provider returned an empty or malformed frame; forgetting to set df.index = pd.DatetimeIndex(df.date); charting non-time-series data (screening tables, ratings lists).

Related errors


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