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

  1. Check the sign and finiteness of the value at its source; log the offending name/value.
  2. Fix unit/sign conventions (e.g. pass 0.05 not -5, and 0.05 not 5 if a ratio is expected).
  3. 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

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


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