OpenBB-finance/OpenBB · warning · EmptyDataError

No results found for '{search_term}'.

Error message

No results found for '{search_term}'.

What it means

EmptyDataError from the CFTC search endpoint (cot_search.py:204) when the Socrata $query built from your search term (and optional filters) returns no matching dataset records. There are two messages: one embedding your search term when you supplied one, and a generic 'No results returned from the CFTC API.' when the term was empty — distinguishing a bad search from an API-wide empty answer.

Source

Thrown at openbb_platform/providers/cftc/openbb_cftc/models/cot_search.py:204

            }
            sub = subcategory_map.get(
                query.subcategory,
                query.subcategory.replace("_", " ").upper(),
            )
            where_parts.append(f"UPPER(commodity_subgroup_name) = '{sub}'")

        if where_parts:
            base_url += "&$where=" + quote(" AND ".join(where_parts))

        url = f"{base_url}&$$app_token={app_token}" if app_token else base_url

        try:
            response = await amake_request(url, **kwargs)
        except OpenBBError as error:
            raise error from error

        if not response:
            raise EmptyDataError(
                f"No results found for '{search_term}'."
                if search_term
                else "No results returned from the CFTC API."
            )

        return response  # type: ignore

    @staticmethod
    def transform_data(
        query: CftcCotSearchQueryParams,
        data: list[dict],
        **kwargs: Any,
    ) -> list[CftcCotSearchData]:
        """Transform the data."""
        results: list[CftcCotSearchData] = []
        seen: set[str] = set()
        for d in data:
            code = d.get("cftc_contract_market_code", "")

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Broaden or correct the term: use official CFTC naming, e.g. 'Crude Oil' or 'WTI' rather than slang.
  2. Drop optional filters (report_type/data_format) to see any match first, then narrow down.
  3. If every term fails, test the raw CFTC Socrata endpoint in a browser to rule out an API outage or schema change.

Example fix

# before
obb.economy.cftc.cot_search(search_term='petrol')

# after
obb.economy.cftc.cot_search(search_term='crude oil')
Defensive patterns

Strategy: fallback

Validate before calling

term = 'crude oil'  # use official CFTC report naming
res = obb.economy.cftc.cot_search(search_term=term)
rows = res.results if hasattr(res, 'results') else res

Try / catch

from openbb_core.provider.utils.errors import EmptyDataError

terms = ['crude oil', 'petroleum', 'energy']
for t in terms:
    try:
        df = obb.economy.cftc.cot_search(search_term=t).to_df()
        if not df.empty:
            break
    except EmptyDataError:
        continue

Prevention

When it happens

Trigger: Searching with a term CFTC dataset titles do not contain (e.g. 'wti crude' vs their official naming); combining search_term with restrictive where-clauses (report_type, data_format) that exclude all matches; searching exotic instruments the CFTC does not track.

Common situations: Using colloquial commodity names instead of CFTC's official report titles; auto-complete flows firing one-character queries; filtering by the wrong granularity ('detail' vs 'disagg') so every row is excluded.

Related errors


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