HKUDS/Vibe-Trading · error · ValueError
preferred rate must be non-negative, got {rate!r}
Error message
preferred rate must be non-negative, got {rate!r} What it means
preferred_return_amount validates its hurdle rate and rejects negative values because the compounding convention for a negative preferred rate is undefined. Only rate >= 0 is accepted.
Source
Thrown at agent/src/quantlib/fundmath.py:961
compounding: One of :data:`PREFERRED_COMPOUNDING`. ``"compound"``
accrues ``(1 + rate) ** years - 1``; ``"simple"`` accrues
``rate * years``.
days_per_year: Day basis for the year fraction.
contribution_kinds: Kind labels counted as capital in.
Returns:
The preferred return owed, as a positive magnitude excluding the return
of capital itself. ``0.0`` when nothing has been drawn.
Raises:
TypeError: If ``series`` is not a ``CashFlowSeries``.
ValueError: If the rate is negative, the compounding convention is
unknown, ``as_of`` precedes a contribution, or ``as_of`` is omitted
for an empty series.
"""
_require_series(series)
if rate < 0.0:
raise ValueError(f"preferred rate must be non-negative, got {rate!r}")
if compounding not in PREFERRED_COMPOUNDING:
raise ValueError(
f"compounding={compounding!r} is not one of {PREFERRED_COMPOUNDING}"
)
if days_per_year <= 0:
raise ValueError(f"days_per_year must be positive, got {days_per_year!r}")
contributions = tuple(series.filter(kind=contribution_kinds))
if not contributions:
return 0.0
if as_of is None:
if series.is_empty:
raise ValueError("as_of is required for an empty series")
measurement = max(series.dates())
else:
measurement = normalize_date(as_of, field_name="as_of")
View on GitHub (pinned to 80ffdda44c)
Solutions
- Pass the rate as a non-negative decimal (0.08 for 8%)
- Check the config/parse step that produced the negative value
- Use 0.0 explicitly for a no-hurdle fund
Example fix
# before preferred_return_amount(series, rate=-0.08) # after preferred_return_amount(series, rate=0.08)
Defensive patterns
Strategy: validation
Validate before calling
if rate < 0:
raise ConfigError(f"hurdle rate must be >= 0, got {rate}") Prevention
- Validate rates at the config boundary
- Use abs() only after confirming the sign error, never as a blanket fix
When it happens
Trigger: Calling preferred_return_amount(series, rate=-0.08) (or european_waterfall/_pooled_entitlement with a negative hurdle rate parameter).
Common situations: Parsing a hurdle like '-8' from config when it was meant as 8%; sign errors when converting an annual rate; unit tests passing negative fixtures.
Related errors
- compounding={compounding!r} is not one of {PREFERRED_COMPOUN
- as_of is required for an empty series
- contribution on {flow.date} is after as_of={measurement}; a
- {label} must be non-negative, got {value!r}
- invalid alpha_id
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/3bea6e4969fbe80b.
Report an issue: GitHub.