{"record":{"id":"6b2973203241cda6","repo":"OpenBB-finance/OpenBB","slug":"data-not-found","errorCode":null,"errorMessage":"Data not found","messagePattern":"Data not found","errorType":"exception","errorClass":"EmptyDataError","httpStatus":null,"severity":"warning","filePath":"openbb_platform/providers/government_us/openbb_government_us/models/treasury_prices.py","lineNumber":110,"sourceCode":"            raise OpenBBError(f\"Expected ISO-8859-1 encoding but got: {r.encoding}\")\n\n        return r.content.decode(\"utf-8\")\n\n    @staticmethod\n    def transform_data(\n        query: GovernmentUSTreasuryPricesQueryParams,\n        data: str,\n        **kwargs: Any,\n    ) -> list[GovernmentUSTreasuryPricesData]:\n        \"\"\"Transform the data.\"\"\"\n        # pylint: disable=import-outside-toplevel\n        from math import isnan  # noqa\n        from io import StringIO\n        from pandas import Index, read_csv, to_datetime\n\n        try:\n            if not data:\n                raise EmptyDataError(\"Data not found\")\n            results = read_csv(StringIO(data), header=0)\n            results.columns = Index(\n                [\n                    \"cusip\",\n                    \"security_type\",\n                    \"rate\",\n                    \"maturity_date\",\n                    \"call_date\",\n                    \"bid\",\n                    \"offer\",\n                    \"eod_price\",\n                ]\n            )\n            results[\"date\"] = query.date.strftime(\"%Y-%m-%d\")  # type: ignore\n            for col in [\"maturity_date\", \"call_date\"]:\n                results[col] = (\n                    (\n                        to_datetime(results[col], format=\"%m/%d/%Y\").dt.strftime(","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/government_us/openbb_government_us/models/treasury_prices.py#L92-L128","documentation":"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.","triggerScenarios":"Requesting treasury_prices for a date with no published end-of-day prices: weekends, federal holidays, or dates before the dataset's coverage begins.","commonSituations":"Date-range loops that step over non-trading days; historical research requesting dates earlier than the Treasury's Treasury Prices dataset availability.","solutions":["Use a valid business date for the query.","In batch scripts, wrap the call and skip dates that raise this error rather than aborting the whole run.","Pre-filter your date list to US business days (e.g. with pandas' USFederalHolidayCalendar) before calling."],"exampleFix":"# before\nfor d in date_range:\n    df = obb.equity.gov.treasury_prices(date=d).to_df()\n\n# after\nfor d in business_days:\n    try:\n        df = obb.equity.gov.treasury_prices(date=d).to_df()\n    except OpenBBError:\n        continue  # non-trading day","handlingStrategy":"try-catch","validationCode":"from pandas.tseries.holiday import USFederalHolidayCalendar\nfrom datetime import date\n\ncal = USFederalHolidayCalendar()\nholidays = {d.date() for d in cal.holidays(start=\"1970-01-01\", end=\"2100-12-31\")}\n\ndef is_trading_day(d: date) -> bool:\n    return d.weekday() < 5 and d not in holidays","typeGuard":null,"tryCatchPattern":"try:\n    df = obb.equity.gov.treasury_prices(date=d).to_df()\nexcept OpenBBError as e:\n    if \"Data not found\" in str(e):\n        continue  # non-trading day, skip\n    raise","preventionTips":["Only request US business days.","Treat 'Data not found' as a skip signal in backfills, not a fatal error.","Cache successful responses to avoid re-fetching the same date."],"tags":["empty-data","treasury","calendar"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}