HKUDS/Vibe-Trading · error · ValuationError
run_dcf: discounting_convention must be one of {DISCOUNTING_
Error message
run_dcf: discounting_convention must be one of {DISCOUNTING_CONVENTIONS}, got {discounting_convention!r} What it means
run_dcf requires discounting_convention to be one of DISCOUNTING_CONVENTIONS (e.g. mid-year vs full-year discounting conventions). Passing any other string raises ValuationError before projections are built, because the convention controls how discount factors are computed for every period.
Source
Thrown at agent/src/quantlib/valuation/dcf.py:1317
A :class:`DCFResult` with every intermediate figure visible.
Raises:
MissingInputError: If any required key is absent from ``inputs``.
ValuationError: If ``capital_structure_basis``,
``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")View on GitHub (pinned to 80ffdda44c)
Solutions
- Import DISCOUNTING_CONVENTIONS and use an exact member.
- Fix hyphen/underscore or casing mismatch in the config value.
- Add a schema check on your config dict that whitelists both enum fields before calling run_dcf.
Example fix
// before run_dcf(..., discounting_convention="mid_year") // after run_dcf(..., discounting_convention="mid-year") # exact member of DISCOUNTING_CONVENTIONS
Defensive patterns
Strategy: validation
Validate before calling
from quantlib.valuation.dcf import DISCOUNTING_CONVENTIONS assert discounting_convention in DISCOUNTING_CONVENTIONS
Type guard
def is_valid_convention(c: str) -> bool:
from quantlib.valuation.dcf import DISCOUNTING_CONVENTIONS
return isinstance(c, str) and c in DISCOUNTING_CONVENTIONS Try / catch
except ValuationError as e:
if 'discounting_convention' in str(e): raise ConfigError(str(e)) from e Prevention
- Use keyword arguments for enum-like parameters
- Normalize config strings (strip/lower) against the module constant sets
When it happens
Trigger: Calling run_dcf with discounting_convention set to a string not in DISCOUNTING_CONVENTIONS — typo like 'mid_year' instead of the canonical 'mid-year', or passing a capital_structure_basis value by mistake.
Common situations: Hand-written config files with hyphen/underscore mismatches; swapping two enum arguments positionally; version upgrades that renamed conventions.
Related errors
- run_dcf: capital_structure_basis must be one of {CAPITAL_STR
- run_dcf: terminal_value_method must be one of {TERMINAL_VALU
- {model}: {expected_name!r} must be supplied as an Assumption
- {model}: expected an Assumption named {expected_name!r}, got
- wacc: capital_structure_basis must be one of {CAPITAL_STRUCT
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/a44d0dbfd7610c76.
Report an issue: GitHub.