OpenBB-finance/OpenBB · error · ValueError
Column '{target}', or 'close', not found in the data.
Error message
Column '{target}', or 'close', not found in the data. What it means
The moving-average charting view (technical_views.py, ma function) raises this ValueError when neither the requested target column nor a fallback 'close' column exists in the data. The MA overlay must be computed on one price series; if data lacks both the specified target (default 'close') and 'close', there is no series to smooth.
Source
Thrown at openbb_platform/extensions/technical/openbb_technical/technical_views.py:460
data = basemodel_to_df(data, index=index)
window = (
kwargs.get("length", [])
if "length" in kwargs and kwargs.get("length") is not None
else [50]
)
offset = kwargs.get("offset", 0)
target = (
kwargs.get("target")
if "target" in kwargs and kwargs.get("target") is not None
else "close"
)
if target not in data.columns and "close" in data.columns:
target = "close"
if target not in data.columns and "close" not in data.columns:
raise ValueError(f"Column '{target}', or 'close', not found in the data.")
df = data.copy()
if target in data.columns:
df = df[[target]]
df.columns = ["close"]
title = (
kwargs.get("title")
if "title" in kwargs and kwargs.get("title") is not None
else f"{ma_type.upper()}"
)
fig = OpenBBFigure()
fig = fig.create_subplots(
1,
1,
shared_xaxes=True,
vertical_spacing=0.06,
horizontal_spacing=0.01,View on GitHub (pinned to 3e071fcc2c)
Solutions
- Inspect data.columns and pass an existing numeric column as target: charting(target='Close'.lower())
- Rename your column to 'close' before calling: df = df.rename(columns={'Close': 'close'})
- Use an OBBject from a price endpoint that guarantees a close field
Example fix
# before res.charting(target='adj_close') # no such column # after df = res.to_df().rename(columns=str.lower) res.charting(data=df, target='close')
Defensive patterns
Strategy: type-guard
Validate before calling
cols = {c.lower() for c in df.columns}
assert 'close' in cols or (target and target.lower() in cols), 'no plottable price column' Type guard
def has_price_column(df: pd.DataFrame, target: str | None = None) -> bool:
cols = {c.lower() for c in df.columns}
return 'close' in cols or (target is not None and target.lower() in cols) Try / catch
try:
res.charting(target='adj_close')
except ValueError as e:
if 'not found in the data' in str(e):
res.charting(data=res.to_df().rename(columns=str.lower), target='close') Prevention
- Lowercase column names before charting
- Verify target exists with 'target in df.columns'
- Prefer endpoints guaranteed to include a close field
When it happens
Trigger: Calling the MA chart with kwargs['target']='adj_close' when the frame has no adj_close and no close column; charting an OBBject from an endpoint whose output has no 'close' field (e.g. some macro or custom data); case-mismatched column names like 'Close'.
Common situations: Passing target names that don't exist in the provider's schema; using custom DataFrames with uppercase or renamed columns; endpoints whose results never include close prices.
Related errors
- Error: No data to plot.
- Expiration field not found in the data.
- Price field not found in the data.
- Column '{target_col}' not found in the data.
- No 'weight' column found in the data.
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/ddb7c7b6f2a2c78f.
Report an issue: GitHub.