OpenBB-finance/OpenBB · warning · EmptyDataError

The request was returned empty.

Error message

The request was returned empty.

What it means

Raised by FederalReservePrimaryDealerPositioningFetch after asyncio.gather over all week URLs when none of the responses contained a 'pd'.'timeseries' payload. The fetcher collects timeseries from each URL and only errors when the aggregated list is empty, so partial outages still return data. It is an EmptyDataError, rendered by OpenBB as a no-results condition.

Source

Thrown at openbb_platform/providers/federal_reserve/openbb_federal_reserve/models/primary_dealer_positioning.py:125

        symbols = POSITION_GROUPS_TO_SERIES.get(query.category, [])
        results: list[dict] = []

        base_url = "https://markets.newyorkfed.org/api/pd/get/"
        urls = [base_url + symbol + ".json" for symbol in symbols]

        async def get_one(url):
            """Get data for a single URL."""
            result = await amake_request(url)
            if isinstance(result, dict):
                data = result.get("pd", {}).get("timeseries")
                if data:
                    results.extend(data)

        await asyncio.gather(*[get_one(url) for url in urls])

        if not results:
            raise EmptyDataError("The request was returned empty.")

        return results

    @staticmethod
    def transform_data(
        query: FederalReservePrimaryDealerPositioningQueryParams,
        data: list[dict],
        **kwargs: Any,
    ) -> list[FederalReservePrimaryDealerPositioningData]:
        """Transform the data."""
        # pylint: disable=import-outside-toplevel
        from openbb_federal_reserve.utils.primary_dealer_statistics import (
            POSITION_SERIES_TO_FIELD,
            POSITION_SERIES_TO_TITLE,
        )
        from pandas import DataFrame

        df = DataFrame(data)

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Inspect one of the generated URLs manually and check the response still contains the 'pd' -> 'timeseries' keys; if renamed, update the parser.
  2. Verify the requested week dates fall within the dataset's published range.
  3. Catch EmptyDataError upstream and degrade to an empty DataFrame or cached data.

Example fix

try:
    res = await obb.fixedincome.corporate.primary_dealer_positioning(provider='federal_reserve')
except EmptyDataError:
    res = None
# optionally: verify shape first
# import httpx; r = await httpx.AsyncClient().get(url); assert 'pd' in r.json()
Defensive patterns

Strategy: try-catch

Try / catch

try:
    res = await obb.fixedincome.corporate.primary_dealer_positioning(provider='federal_reserve')
except EmptyDataError:
    res = None

Prevention

When it happens

Trigger: Calling the primary dealer positioning endpoint where every weekly URL response lacks result['pd']['timeseries'] — e.g. the API changed its JSON shape, all requested weeks are outside the published window, or the service is down and amake_request returns non-dict results that are silently skipped.

Common situations: NY Fed API schema change (key renamed from 'pd'); requesting weeks before data publication started; network egress blocked so every get_one returns nothing without raising.

Related errors


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