HKUDS/Vibe-Trading · error · ValueError
compounding={compounding!r} is not one of {PREFERRED_COMPOUN
Error message
compounding={compounding!r} is not one of {PREFERRED_COMPOUNDING} What it means
The preferred-return calculation only supports the compounding conventions enumerated in PREFERRED_COMPOUNDING (typically 'simple' and 'compound'). Any other string is rejected up front rather than silently falling back to a default.
Source
Thrown at agent/src/quantlib/fundmath.py:963
``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")
total = 0.0
for flow in contributions:View on GitHub (pinned to 80ffdda44c)
Solutions
- Use one of the accepted values: inspect PREFERRED_COMPOUNDING (e.g. 'simple' or 'compound')
- Whitelist/validate user-supplied compounding strings before passing them through
- For custom frequencies, compute the preferred return yourself outside this API
Example fix
# before preferred_return_amount(series, rate=0.08, compounding="monthly") # after preferred_return_amount(series, rate=0.08, compounding="compound")
Defensive patterns
Strategy: type-guard
Validate before calling
from agent.src.quantlib.fundmath import PREFERRED_COMPOUNDING assert compounding in PREFERRED_COMPOUNDING
Type guard
def is_valid_compounding(c: str) -> bool:
return c in PREFERRED_COMPOUNDING Prevention
- Whitelist user input against PREFERRED_COMPOUNDING before calling
- Fail fast on unknown compounding strings in config parsing
When it happens
Trigger: Calling preferred_return_amount(series, rate=0.08, compounding="monthly") or "continuous", or a typo like "compond".
Common situations: Assuming arbitrary compounding frequencies are supported; passing a value from user config without whitelisting it; typo in the literal.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- preferred rate must be non-negative, got {rate!r}
- as_of is required for an empty series
- contribution on {flow.date} is after as_of={measurement}; a
- unknown entity_type {self.entity_type!r}; expected one of: {
- unknown security_type {self.security_type!r}; expected one o
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/2995fb4ca9e7a457.
Report an issue: GitHub.