HKUDS/Vibe-Trading · error · ValuationError
{model}: {name} must be a finite positive number, got {numer
Error message
{model}: {name} must be a finite positive number, got {numeric} What it means
After successful float coercion, require_positive rejects values that are zero, negative, NaN, or infinite. These are quantities (e.g. share counts, growth factors) where <=0 or non-finite is meaningless, so the model refuses rather than emitting nonsense output.
Source
Thrown at agent/src/quantlib/valuation/contracts.py:157
"""Check a value that is meaningless at or below zero.
Args:
value: The value to check, e.g. a share count or a discount rate.
name: Field name for the error message.
model: Model name for the error message.
Returns:
``value`` as a float.
Raises:
ValuationError: If the value is not a finite number greater than zero.
"""
try:
numeric = float(value)
except (TypeError, ValueError) as exc:
raise ValuationError(f"{model}: {name} must be a number, got {value!r}") from exc
if not numeric > 0.0 or numeric != numeric or numeric in (float("inf"), float("-inf")):
raise ValuationError(
f"{model}: {name} must be a finite positive number, got {numeric}"
)
return numeric
View on GitHub (pinned to 80ffdda44c)
Solutions
- Check the sign and finiteness of the value at its source; log the offending name/value.
- Fix unit/sign conventions (e.g. pass 0.05 not -5, and 0.05 not 5 if a ratio is expected).
- Guard: if not (math.isfinite(v) and v > 0): repair or raise before the call.
Example fix
# before terminal_growth = math.nan run_dcf(..., terminal_growth=terminal_growth) # after terminal_growth = 0.02 assert math.isfinite(terminal_growth) and terminal_growth > 0
Defensive patterns
Strategy: validation
Validate before calling
v = float(value)
if not (math.isfinite(v) and v > 0):
raise ValueError(f'{name} must be finite positive, got {v}') Type guard
def is_positive_finite(v):
return isinstance(v, (int, float)) and math.isfinite(v) and v > 0 Try / catch
except ValuationError as e:
if 'finite positive' in str(e):
log.error('fix sign/unit for %s', e); raise Prevention
- Check sign conventions for percentage/ratio inputs
- Filter NaN from aggregations before model calls
When it happens
Trigger: Passing 0, -0.02, math.nan, or float('inf') to any parameter validated by require_positive — e.g. a negative discount rate or a NaN share count from an empty DataFrame aggregation.
Common situations: Sign errors (percentages supplied as -5 for a 5% decline); unit mistakes producing 0 after integer division; NaN from empty aggregations; inf from divide-by-zero upstream.
Related errors
- {model}: {name} must be supplied as a non-negative magnitude
- valuation on {when} must be finite, got {raw_value!r}; a mis
- {model}: {name} must be a finite number, got {val!r}
- comps: total_debt must be a finite number, got {total_debt!r
- comps: cash_and_equivalents must be a finite number, got {ca
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/6dfa31aa938626a7.
Report an issue: GitHub.