HKUDS/Vibe-Trading · error · ValuationError
wacc: market value of equity plus debt is zero (D + E = 0);
Error message
wacc: market value of equity plus debt is zero (D + E = 0); capital-structure weights are undefined
What it means
With basis 'current', wacc() computes weights as E/(D+E) and D/(D+E); if both market values are zero (or sum to <= 0, which given non-negative validation means both zero), the weights are mathematically undefined and a ValuationError is raised instead of returning NaN.
Source
Thrown at agent/src/quantlib/valuation/dcf.py:458
missing = [
name
for name, value in (
("market_value_of_equity", market_value_of_equity),
("market_value_of_debt", market_value_of_debt),
)
if value is None
]
if missing:
raise MissingInputError(missing, "wacc")
equity_mv = _require_nonnegative(
market_value_of_equity, "market_value_of_equity", "wacc"
)
debt_mv = _require_nonnegative(
market_value_of_debt, "market_value_of_debt", "wacc"
)
total_mv = equity_mv + debt_mv
if total_mv <= 0.0:
raise ValuationError(
"wacc: market value of equity plus debt is zero (D + E = 0); "
"capital-structure weights are undefined"
)
equity_weight = equity_mv / total_mv
debt_weight = debt_mv / total_mv
else:
missing = [
name
for name, value in (
("target_equity_weight", target_equity_weight),
("target_debt_weight", target_debt_weight),
)
if value is None
]
if missing:
raise MissingInputError(missing, "wacc")
equity_weight = _require_finite(
target_equity_weight, "target_equity_weight", "wacc"View on GitHub (pinned to 80ffdda44c)
Solutions
- Skip entities with zero total market value or handle them in a separate branch
- Use capital_structure_basis='target' with target weights for such entities
- Pre-filter input rows: if equity_mv + debt_mv <= 0, exclude before calling wacc
Example fix
# before
for row in rows:
wacc(..., market_value_of_equity=row['e_mv'], market_value_of_debt=row['d_mv'])
# after
for row in rows:
if row['e_mv'] + row['d_mv'] <= 0:
continue
wacc(..., market_value_of_equity=row['e_mv'], market_value_of_debt=row['d_mv']) Defensive patterns
Strategy: validation
Validate before calling
if (e_mv or 0) + (d_mv or 0) <= 0:
skip(ticker, reason='zero market cap')
wacc(..., market_value_of_equity=e_mv, market_value_of_debt=d_mv) Type guard
def has_positive_total_mv(e_mv: float, d_mv: float) -> bool:
return (e_mv + d_mv) > 0 Try / catch
try:
wacc(...)
except ValuationError as e:
if 'D + E = 0' in str(e):
return wacc(..., capital_structure_basis='target', target_equity_weight=1.0, target_debt_weight=0.0)
raise Prevention
- Filter zero-market-cap entities upstream
- Use target weights for shells/pre-IPO entities
- Never substitute 0 for missing market values
When it happens
Trigger: wacc(capital_structure_basis='current', market_value_of_equity=0, market_value_of_debt=0) — e.g. a pre-IPO shell entity or a placeholder row of zeros in a dataset.
Common situations: Screening universes containing shell/holding companies with zero market cap; default-zero rows from joins where the market-data fetch failed.
Related errors
- {model}: {name} must be a number, got {value!r}
- {model}: capital-structure weights must be non-negative, got
- {model}: capital-structure weights must sum to 1 (within {_R
- WACCResult.wacc={self.wacc!r} does not match the weighted bl
- 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/8b2b83febbcdd530.
Report an issue: GitHub.