OpenBB-finance/OpenBB · error · OpenBBError

Invalid [{section}] {key}={val}. Choose one of the following

Error message

Invalid [{section}] {key}={val}. Choose one of the following options:
{', '.join(d_check_screener[key])}.

What it means

A preset INI key was recognized, but its value is not in the allowed option set for that filter (d_check_screener[key]). The message lists every legal value for that key. Finviz filters are enumerated choices, not free-form numbers or booleans.

Source

Thrown at openbb_platform/providers/finviz/openbb_finviz/models/equity_screener.py:623

        if preset is not None:
            preset_filter = configparser.RawConfigParser()
            preset_filter.optionxform = str  # type: ignore
            preset_filter.read(preset_choices[preset])
            d_general = preset_filter["General"]
            d_filters = {
                **preset_filter["Descriptive"],
                **preset_filter["Fundamental"],
                **preset_filter["Technical"],
            }
            for section in ["General", "Descriptive", "Fundamental", "Technical"]:
                for key, val in {**preset_filter[section]}.items():
                    if key not in d_check_screener:
                        raise OpenBBError(
                            f"The screener variable {section}.{key} shouldn't exist!\n"
                        )

                    if val not in d_check_screener[key]:
                        raise OpenBBError(
                            f"Invalid [{section}] {key}={val}. "
                            f"Choose one of the following options:\n{', '.join(d_check_screener[key])}.\n"
                        )

            d_filters = {k: v for k, v in d_filters.items() if v is not None}
            screen.set_filter(filters_dict=d_filters)
            asc = None

            asc = d_general.get("Ascend")

            if asc is not None:
                ascend = asc == "true"

            df_screen = screen.screener_view(
                order=d_general.get("Order", "Change"),
                limit=limit if limit else 100000,
                ascend=ascend,
                sleep_sec=sleep,

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Replace the value with one of the options listed in the error message for that key
  2. Copy value syntax verbatim from the shipped screener_template.ini
  3. For numeric concepts, choose the closest bucket (e.g. 'Over 10', 'Under 5') rather than a raw number

Example fix

; before
[Fundamental]
P/E = 12.5        ; raw number -> Invalid [Fundamental] P/E=12.5

; after
[Fundamental]
P/E = Over 10
Defensive patterns

Strategy: validation

Validate before calling

import configparser

def validate_values(ini_path: str, allowed: dict[str, set[str]]) -> list[str]:
    c = configparser.RawConfigParser(); c.optionxform = str; c.read(ini_path)
    bad = []
    for s in c.sections():
        for k, v in c[s].items():
            if k in allowed and v not in allowed[k]:
                bad.append(f"[{s}] {k}={v}")
    return bad

Prevention

When it happens

Trigger: Setting P/E = 10 (raw number) instead of a bucket like 'Over 10'; 'Ascend = yes' instead of 'true'; country codes or exchange values not in the enumeration.

Common situations: Users writing natural numeric values where Finviz expects range buckets; template edits that change only the value but keep wrong syntax; locale differences ('true' vs 'True' vs 'yes').

Related errors


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