OpenBB-finance/OpenBB · warning · EmptyDataError

Data not found

Error message

Data not found

What it means

Raised inside transform_data when the fetched CSV string is empty (falsy). It is wrapped in the provider's standard try/except that converts EmptyDataError into an OpenBBError, so the caller sees a clean 'Data not found' instead of a parser traceback. It means the request succeeded but returned zero content for the requested date.

Source

Thrown at openbb_platform/providers/government_us/openbb_government_us/models/treasury_prices.py:110

            raise OpenBBError(f"Expected ISO-8859-1 encoding but got: {r.encoding}")

        return r.content.decode("utf-8")

    @staticmethod
    def transform_data(
        query: GovernmentUSTreasuryPricesQueryParams,
        data: str,
        **kwargs: Any,
    ) -> list[GovernmentUSTreasuryPricesData]:
        """Transform the data."""
        # pylint: disable=import-outside-toplevel
        from math import isnan  # noqa
        from io import StringIO
        from pandas import Index, read_csv, to_datetime

        try:
            if not data:
                raise EmptyDataError("Data not found")
            results = read_csv(StringIO(data), header=0)
            results.columns = Index(
                [
                    "cusip",
                    "security_type",
                    "rate",
                    "maturity_date",
                    "call_date",
                    "bid",
                    "offer",
                    "eod_price",
                ]
            )
            results["date"] = query.date.strftime("%Y-%m-%d")  # type: ignore
            for col in ["maturity_date", "call_date"]:
                results[col] = (
                    (
                        to_datetime(results[col], format="%m/%d/%Y").dt.strftime(

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Use a valid business date for the query.
  2. In batch scripts, wrap the call and skip dates that raise this error rather than aborting the whole run.
  3. Pre-filter your date list to US business days (e.g. with pandas' USFederalHolidayCalendar) before calling.

Example fix

# before
for d in date_range:
    df = obb.equity.gov.treasury_prices(date=d).to_df()

# after
for d in business_days:
    try:
        df = obb.equity.gov.treasury_prices(date=d).to_df()
    except OpenBBError:
        continue  # non-trading day
Defensive patterns

Strategy: try-catch

Validate before calling

from pandas.tseries.holiday import USFederalHolidayCalendar
from datetime import date

cal = USFederalHolidayCalendar()
holidays = {d.date() for d in cal.holidays(start="1970-01-01", end="2100-12-31")}

def is_trading_day(d: date) -> bool:
    return d.weekday() < 5 and d not in holidays

Try / catch

try:
    df = obb.equity.gov.treasury_prices(date=d).to_df()
except OpenBBError as e:
    if "Data not found" in str(e):
        continue  # non-trading day, skip
    raise

Prevention

When it happens

Trigger: Requesting treasury_prices for a date with no published end-of-day prices: weekends, federal holidays, or dates before the dataset's coverage begins.

Common situations: Date-range loops that step over non-trading days; historical research requesting dates earlier than the Treasury's Treasury Prices dataset availability.

Related errors


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