HKUDS/Vibe-Trading · error · ValuationError

run_dcf: terminal_value_method must be one of {TERMINAL_VALU

Error message

run_dcf: terminal_value_method must be one of {TERMINAL_VALUE_METHODS}, got {terminal_value_method!r}

What it means

run_dcf only accepts terminal_value_method values from TERMINAL_VALUE_METHODS (typically 'perpetuity_growth' and 'exit_multiple'). An unrecognized method name raises ValuationError up front, since the terminal value dominates the DCF result and an unknown formula would silently produce garbage.

Source

Thrown at agent/src/quantlib/valuation/dcf.py:1322

            ``discounting_convention`` or ``terminal_value_method`` is
            unrecognised; if ``terminal_growth`` or ``exit_multiple`` is not
            the matching :class:`Assumption`; if ``terminal_growth.value >=``
            the built WACC; if any capital-structure, FCFF-bridge or
            balance-sheet input fails its own guard (see :func:`wacc`,
            :func:`fcff_bridge`, :func:`terminal_value`, :func:`equity_bridge`).
    """
    if capital_structure_basis not in CAPITAL_STRUCTURE_BASES:
        raise ValuationError(
            f"run_dcf: capital_structure_basis must be one of "
            f"{CAPITAL_STRUCTURE_BASES}, got {capital_structure_basis!r}"
        )
    if discounting_convention not in DISCOUNTING_CONVENTIONS:
        raise ValuationError(
            f"run_dcf: discounting_convention must be one of "
            f"{DISCOUNTING_CONVENTIONS}, got {discounting_convention!r}"
        )
    if terminal_value_method not in TERMINAL_VALUE_METHODS:
        raise ValuationError(
            f"run_dcf: terminal_value_method must be one of "
            f"{TERMINAL_VALUE_METHODS}, got {terminal_value_method!r}"
        )

    structure_fields = (
        DCF_CURRENT_STRUCTURE_FIELDS
        if capital_structure_basis == "current"
        else DCF_TARGET_STRUCTURE_FIELDS
    )
    require_inputs(inputs, (*DCF_BASE_REQUIRED_FIELDS, *structure_fields), model="run_dcf")

    terminal_growth = _require_assumption(inputs["terminal_growth"], "terminal_growth", "run_dcf")
    exit_multiple = _require_assumption(inputs["exit_multiple"], "exit_multiple", "run_dcf")

    wacc_build = wacc(
        risk_free_rate=inputs["risk_free_rate"],
        beta=inputs["beta"],
        equity_risk_premium=inputs["equity_risk_premium"],

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Import TERMINAL_VALUE_METHODS and pass an exact member.
  2. Correct spelling/separator style to match the module constants.
  3. Whitelist terminal_value_method in config validation before run_dcf.

Example fix

// before
run_dcf(..., terminal_value_method="exit-multiple")
// after
run_dcf(..., terminal_value_method="exit_multiple")
Defensive patterns

Strategy: validation

Validate before calling

from quantlib.valuation.dcf import TERMINAL_VALUE_METHODS
assert terminal_value_method in TERMINAL_VALUE_METHODS

Type guard

def is_valid_tv_method(m: str) -> bool:
    from quantlib.valuation.dcf import TERMINAL_VALUE_METHODS
    return isinstance(m, str) and m in TERMINAL_VALUE_METHODS

Try / catch

except ValuationError as e:
    if 'terminal_value_method' in str(e): fix_and_retry(e)

Prevention

When it happens

Trigger: Calling run_dcf(terminal_value_method=...) with a string not in TERMINAL_VALUE_METHODS, e.g. 'exit-multiple' with a hyphen, 'GordonGrowth', or an entirely made-up method.

Common situations: Users porting terminology from other models (Excel templates, other libraries) that name terminal-value methods differently; LLM-generated kwargs with guessed enum strings.

Related errors


AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28). Data as JSON: /api/errors/7f7a381c3e5b45df. Report an issue: GitHub.