OpenBB-finance/OpenBB · warning · EmptyDataError

No data found for {_id.replace('%', '')}.

Error message

No data found for {_id.replace('%', '')}.

What it means

EmptyDataError from the CFTC Commitments of Traders fetcher (cot.py:1926) when the Socrata-style CFTC API returns a falsy/empty response for the constructed report URL. The message echoes the requested dataset id (with %20 encoding stripped) so you can see which report series came back empty. It signals 'the API answered but had zero records for this query', not a network failure.

Source

Thrown at openbb_platform/providers/cftc/openbb_cftc/models/cot.py:1926

                f"OR UPPER(cftc_contract_market_code) like UPPER('{_id}') "
                f"OR UPPER(commodity_group_name) like UPPER('{_id}') "
                f"OR UPPER(commodity_subgroup_name) like UPPER('{_id}'))"
            )
            if _id
            else base_url
        )
        url = f"{url}{order}"

        if app_token:
            url += f"&$$app_token={app_token}"

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

        if not response:
            raise EmptyDataError(f"No data found for {_id.replace('%', '')}.")

        return response  # type: ignore

    @staticmethod
    def transform_data(
        query: CftcCotQueryParams,
        data: list[dict],
        **kwargs: Any,
    ) -> list[CftcCotData]:
        """Transform and validate the data."""
        response = data.copy()
        string_cols = [
            "market_and_exchange_names",
            "cftc_contract_market_code",
            "cftc_market_code",
            "cftc_region_code",
            "cftc_commodity_code",
            "cftc_contract_market_code_quotes",

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Verify the report id exists in cot_search (the CFTC search endpoint) and copy the exact id string.
  2. If asking for the latest report, add a date fallback: request the prior week when today's publication is not out yet.
  3. Log the full assembled URL and open it in a browser to confirm the API truly returns zero rows; if the URL is malformed, check query params (order, limit, $where).

Example fix

# before
obb.economy.cftc.cot(id='nonexistent-dataset').to_df()

# after
res = obb.economy.cftc.cot_search('crude oil')
id_ = res.to_df()['id'][0]  # e.g. '100800' style series id
obb.economy.cftc.cot(id=id_).to_df()
Defensive patterns

Strategy: fallback

Validate before calling

known = obb.economy.cftc.cot_search('crude oil').to_df()
assert not known.empty, 'no CFTC series matches the term'
report_id = known['id'].iloc[0]

Try / catch

from openbb_core.provider.utils.errors import EmptyDataError

try:
    data = obb.economy.cftc.cot(id=report_id).to_df()
except EmptyDataError as e:
    log.warning('CFTC empty for %s: %s', report_id, e)
    data = obb.economy.cftc.cot(id=report_id, report_date=previous_friday()).to_df()

Prevention

When it happens

Trigger: Requesting a CoT report id that does not exist or is discontinued; a combination of id/report_type/format/granularity that matches zero rows (e.g. a future with no data for that time frame); asking for a current report before the CFTC has published it (reports lag by days); Socrata returning [] due to a malformed $order or filter appended to the URL.

Common situations: Typos in dataset ids taken from URLs (e.g. clipped '20%20Futures' strings); new asset classes the CFTC does not cover; scripts run on Friday expecting the Friday report before publication cutoff; CFTC re-issuing Socrata dataset ids after site migrations.

Related errors


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