OpenBB-finance/OpenBB · error · ValueError
Invalid region, '{region}', for factor '{factor}'. Only 'ame
Error message
Invalid region, '{region}', for factor '{factor}'. Only 'america' is supported. What it means
Fama-French factors query-model validator: the short-term and long-term reversal factors ('st_reversal', 'lt_reversal') exist only in the North American dataset, so requesting them with region != 'america' raises this ValueError during parameter validation, before any network call.
Source
Thrown at openbb_platform/providers/famafrench/openbb_famafrench/models/factors.py:122
description="End date of the data. Defaults to the complete data range.",
json_schema_extra={
"x-widget_config": {
"value": "$currentDate",
"description": "End date of the factor data.",
}
},
)
@model_validator(mode="before")
@classmethod
def validate_region_and_factor(cls, values):
"""Validate region and factor combination."""
region = values.get("region", "america")
factor = factors_dict.get(values.get("factor", "3_factors"), "")
frequency = values.get("frequency", "")
if factor and factor in ["st_reversal", "lt_reversal"] and region != "america":
raise ValueError(
f"Invalid region, '{region}', for factor '{factor}'. Only 'america' is supported."
)
if region and region not in list(FACTOR_REGION_MAP):
raise ValueError(
f"Invalid region: '{region}'. "
+ "Valid regions are: "
+ ", ".join(FACTOR_REGION_MAP.keys())
)
regional_factors = FACTOR_REGION_MAP[region]
if factor not in regional_factors.get("factors", {}):
raise ValueError(
f"Invalid factor: '{factor}' for region: '{region}'. "
+ "Valid factors are: "
+ ", ".join(regional_factors.get("factors", {}).keys())
)View on GitHub (pinned to 3e071fcc2c)
Solutions
- Set region='america' when requesting st_reversal or lt_reversal.
- Or choose a factor that exists in your target region (see FACTOR_REGION_MAP[region]['factors']).
- Build region-aware factor lists in your UI from FACTOR_REGION_MAP instead of a flat list.
Example fix
# before
Fetcher(query={'factor': 'st_reversal', 'region': 'europe'})
# after
Fetcher(query={'factor': 'st_reversal', 'region': 'america'}) Defensive patterns
Strategy: validation
Validate before calling
AMERICA_ONLY = {'st_reversal', 'lt_reversal'}
def combo_ok(region: str, factor: str) -> bool:
return factor not in AMERICA_ONLY or region == 'america' Try / catch
try:
res = await obb.economy.famafrench.factors(factor=f, region=r, provider='famafrench')
except ValueError as e:
if 'Only \'america\' is supported' in str(e):
r = 'america'
res = await obb.economy.famafrench.factors(factor=f, region=r, provider='famafrench')
else:
raise Prevention
- Special-case reversal factors in region-aware UIs
- Validate (region, factor) pairs before batch submission
When it happens
Trigger: Calling the Fama-French factors endpoint with factor='st_reversal' (or 'lt_reversal') and region='europe'/'japan'/'asia_pacific_ex_japan'/'north_america'/etc.
Common situations: Reusing a parameter set across regions in batch jobs; UIs that list all factors regardless of selected region; users assuming reversal factors are global like the 3/5-factor models.
Related errors
- Invalid region: '{region}'. Valid regions are: {", ".join(FA
- Invalid factor: '{factor}' for region: '{region}'. Valid fac
- Invalid frequency: '{frequency}' for factor: '{factor}' in r
- Invalid dataset, {dataset}
- The request was returned empty. This may be due to an invali
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/c02ec01f1fec5b3d.
Report an issue: GitHub.