HKUDS/Vibe-Trading · error · ValueError

carry_rate must be in [0, 1), got {carry_rate!r}

Error message

carry_rate must be in [0, 1), got {carry_rate!r}

What it means

Carry (performance fee) rate must lie in [0, 1): 0 means no carry and values >= 1 (100%) are meaningless, and exactly 1 makes the GP take everything with no LP residual defined.

Source

Thrown at agent/src/quantlib/fundmath.py:1175

            exceed ``carry_rate``, or the tier could never complete.

    Returns:
        A :class:`WaterfallResult` whose tiers sum exactly to ``distributable``.

    Raises:
        ValueError: If any amount is negative, if ``carry_rate`` is outside
            ``[0, 1)``, if ``catch_up_rate`` is outside ``[0, 1]``, or if a
            non-zero ``catch_up_rate`` does not exceed ``carry_rate``.
    """
    for label, value in (
        ("distributable", distributable),
        ("contributed_capital", contributed_capital),
        ("preferred_amount", preferred_amount),
    ):
        if value < 0.0:
            raise ValueError(f"{label} must be non-negative, got {value!r}")
    if not 0.0 <= carry_rate < 1.0:
        raise ValueError(f"carry_rate must be in [0, 1), got {carry_rate!r}")
    if not 0.0 <= catch_up_rate <= 1.0:
        raise ValueError(f"catch_up_rate must be in [0, 1], got {catch_up_rate!r}")
    if catch_up_rate > 0.0 and catch_up_rate <= carry_rate:
        raise ValueError(
            f"catch_up_rate={catch_up_rate!r} must exceed carry_rate="
            f"{carry_rate!r}, otherwise the catch-up tier can never complete. "
            "Pass catch_up_rate=0.0 for a fund with no catch-up."
        )

    remaining = float(distributable)

    return_of_capital = min(remaining, float(contributed_capital))
    remaining -= return_of_capital

    preferred_paid = min(remaining, float(preferred_amount))
    remaining -= preferred_paid

    if catch_up_rate > 0.0 and carry_rate > 0.0:

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Pass the rate as a fraction: 0.20 for 20%
  2. Divide percent values by 100 at the config boundary

Example fix

# before
waterfall_split(..., carry_rate=20)

# after
waterfall_split(..., carry_rate=20 / 100)
Defensive patterns

Strategy: validation

Validate before calling

assert 0.0 <= carry_rate < 1.0, carry_rate

Type guard

def is_fraction(x: float) -> bool:
    return isinstance(x, (int, float)) and 0.0 <= x < 1.0

Prevention

When it happens

Trigger: Calling waterfall_split(carry_rate=1.0) or 1.2, or passing a percentage (20) instead of a fraction (0.20).

Common situations: Percent-vs-fraction confusion from config files storing '20' for 20%; UI inputs in percent passed through unconverted.

Related errors


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