OpenBB-finance/OpenBB · error · ValueError

Date range cannot exceed 90 days.

Error message

Date range cannot exceed 90 days.

What it means

A Pydantic model_validator ValueError on FMPDiscoveryFilingsQueryParams: FMP's discovery-filings endpoint caps date ranges at 90 days, and the provider enforces that client-side before any request. If both start_date and end_date are set and end_date - start_date exceeds 90 days, validation fails immediately.

Source

Thrown at openbb_platform/providers/fmp/openbb_fmp/models/discovery_filings.py:43

        "end_date": "to",
        "form_type": "formType",
    }

    limit: int | None = Field(
        default=None,
        description="The maximum number of results to return. Default is 10000.",
    )

    @model_validator(mode="before")
    @classmethod
    def _check_date_range(cls, values):
        """Validate date range."""
        start_date = values.get("start_date")
        end_date = values.get("end_date")

        # Validate date range
        if start_date and end_date and end_date - start_date > timedelta(days=90):
            raise ValueError("Date range cannot exceed 90 days.")

        return values


class FMPDiscoveryFilingsData(DiscoveryFilingsData):
    """FMP Discovery Filings Data."""

    final_link: str = Field(
        description="Direct URL to the main document of the filing."
    )


class FMPDiscoveryFilingsFetcher(
    Fetcher[
        FMPDiscoveryFilingsQueryParams,
        list[FMPDiscoveryFilingsData],
    ]
):

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Split the request into multiple chunks of <= 90 days and concatenate the results
  2. Clamp start_date = end_date - timedelta(days=90) if you only need the most recent window
  3. Catch the ValidationError from the Params call and surface a clear 'max 90 days' message to the user/UI

Example fix

# before
res = obb.equity.discovery_filings(provider='fmp', start_date='2024-01-01', end_date='2024-12-31')  # 366 days -> ValueError

# after
from datetime import date, timedelta
chunks = []
start, end = date(2024, 1, 1), date(2024, 12, 31)
while start <= end:
    stop = min(start + timedelta(days=90), end)
    chunks.append(obbc.equity.discovery_filings(provider='fmp', start_date=start, end_date=stop).results)
    start = stop + timedelta(days=1)
Defensive patterns

Strategy: validation

Validate before calling

from datetime import date, timedelta
MAX_SPAN = timedelta(days=90)
if end_date - start_date > MAX_SPAN:
    raise ValueError(f'Date range {start_date}..{end_date} exceeds FMP 90-day cap; chunk it')

Type guard

null

Try / catch

from pydantic import ValidationError
from datetime import timedelta
try:
    res = obb.equity.discovery_filings(provider='fmp', start_date=s, end_date=e)
except ValidationError:
    if e - s > timedelta(days=90):
        raise ValueError('Range too large for FMP; split into <=90 day chunks') from None
    raise

Prevention

When it happens

Trigger: Calling obb.equity.discovery_filings(..., provider='fmp', start_date=..., end_date=...) with a span greater than timedelta(days=90). The check fires during QueryParams construction, so no HTTP request is ever made.

Common situations: Porting code that pulled a year of filings from another provider (which has no such cap), defaulting end_date=today with a hardcoded old start_date, or building UI date-range pickers without a max-span rule.

Related errors


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