OpenBB-finance/OpenBB · warning · EmptyDataError
No data was found for, {query.country}.
Error message
No data was found for, {query.country}. What it means
Raised by FredBalanceOfPaymentsFetch.transform_data when the fetched dict is empty for the requested country. The BOP fetcher maps query.country through BOP_COUNTRIES to a set of FRED series IDs; an empty payload means FRED returned no observations for any series of that country.
Source
Thrown at openbb_platform/providers/fred/openbb_fred/models/balance_of_payments.py:109
country = BOP_COUNTRIES.get(query.country) if query.country else "USA"
query_dict = query.model_dump(exclude_none=True)
query_dict["symbol"] = ",".join(list(get_bop_series(country).values()))
fred_query = FredSeriesQueryParams(**query_dict)
data = await fred_fetcher.aextract_data(fred_query, credentials)
return data
@staticmethod
def transform_data(
query: FredBalanceOfPaymentsQueryParams,
data: dict,
**kwargs: Any,
) -> AnnotatedResult[list[FredBalanceOfPaymentsData]]:
"""Transform data."""
# pylint: disable=import-outside-toplevel
from pandas import DataFrame
if not data:
raise EmptyDataError(f"No data was found for, {query.country}.")
fred_fetcher = FredSeriesFetcher()
country = BOP_COUNTRIES.get(query.country) if query.country else "USA"
query_dict = query.model_dump(exclude_none=True)
query_dict["symbol"] = ",".join(list(get_bop_series(country).values()))
fred_query = FredSeriesQueryParams(**query_dict)
data = fred_fetcher.transform_data(fred_query, data)
series_ids = get_bop_series(country)
col_map = {v: k for k, v in series_ids.items()}
result = data.result # type: ignore
df = (
DataFrame([d.model_dump() for d in result])
.set_index("date")
.sort_index(ascending=False)
)
df = df.rename(columns=col_map)
records = df.reset_index().fillna("N/A").replace("N/A", None).to_dict("records")
return AnnotatedResult(View on GitHub (pinned to 3e071fcc2c)
Solutions
- Use a country present in the BOP_COUNTRIES mapping of the module (e.g. 'united_states' or its listed peers) - read the module's constant if unsure
- Widen the date range to span several quarters - the data is quarterly with long publication lags
- Check the underlying FRED series pages for that country to confirm coverage
- Fall back to another provider for balance-of-payments data
Defensive patterns
Strategy: validation
Validate before calling
from openbb_fred.models.balance_of_payments import BOP_COUNTRIES
assert not query.country or query.country in BOP_COUNTRIES, f'use one of {list(BOP_COUNTRIES)}' Type guard
def is_supported_bop_country(country: str | None, supported: dict) -> bool:
return country is None or country in supported Try / catch
from openbb_core.provider.utils.errors import EmptyDataError
try:
rows = await obb.economy.balance_of_payments(provider='fred', country=c).await_to_list()
except EmptyDataError:
rows = [] Prevention
- Use only countries listed in the module's BOP_COUNTRIES mapping
- Span multiple quarters in date ranges - BOP data is quarterly with long lags
- Cache the supported-country list at startup instead of hardcoding
When it happens
Trigger: Passing a country whose BOP series FRED does not carry (the valid set is limited to entries in BOP_COUNTRIES, defaulting to USA), or a date range where that country's quarterly BOP series has no observations.
Common situations: Requesting countries outside the supported list; querying very recent quarters before FRED publishes BOP data (multi-quarter lag); date windows falling entirely between quarterly observations.
Related errors
- The request was returned with no data.
- The request was returned empty.
- No data found for the given query. Try adjusting the paramet
- The request was returned empty.
- No tables were found for the release, {query.release_id}. Us
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/2a15cd267b0c15af.
Report an issue: GitHub.