HKUDS/Vibe-Trading · error · ValueError

commitment must be non-negative (it is a size, not a signed

Error message

commitment must be non-negative (it is a size, not a signed cash flow), got {self.commitment!r}

What it means

Fund.__post_init__ requires commitment, when provided, to be a non-negative size: float(commitment) < 0 raises because commitment represents the fund's size, not a signed cash flow. The value is stored as float after validation.

Source

Thrown at agent/src/entities/models.py:314

                negative, ``management_fee_rate`` is out of ``[0, 1]``, or
                ``vintage_year`` is implausible.
        """
        super().__post_init__()
        try:
            object.__setattr__(self, "structure", FundStructure(self.structure))
        except ValueError as exc:
            valid = ", ".join(member.value for member in FundStructure)
            raise ValueError(
                f"unknown structure {self.structure!r}; expected one of: {valid}"
            ) from exc
        if self.vintage_year is not None and not 1800 <= int(self.vintage_year) <= 2200:
            raise ValueError(
                f"vintage_year={self.vintage_year!r} is outside the plausible "
                "range 1800-2200"
            )
        if self.commitment is not None:
            if float(self.commitment) < 0:
                raise ValueError(
                    f"commitment must be non-negative (it is a size, not a signed "
                    f"cash flow), got {self.commitment!r}"
                )
            object.__setattr__(self, "commitment", float(self.commitment))
        if self.management_fee_rate is not None:
            rate = float(self.management_fee_rate)
            if not 0.0 <= rate <= 1.0:
                raise ValueError(
                    f"management_fee_rate must be a decimal fraction in [0, 1] "
                    f"(0.02 means 2%), got {self.management_fee_rate!r}"
                )
            object.__setattr__(self, "management_fee_rate", rate)


@dataclass(frozen=True)
class Bond(Instrument):
    """A debt instrument paying scheduled coupons and returning principal.

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Pass the absolute commitment size if the magnitude is correct
  2. Fix the upstream transformation that applied a cash-flow sign convention to a size field
  3. Add an ingest check: warn or reject rows with negative commitment and report them for manual review

Example fix

# before
Fund(instrument_id='f1', commitment=-100_000_000)

# after
Fund(instrument_id='f1', commitment=100_000_000)
Defensive patterns

Strategy: validation

Validate before calling

commitment = row.get('commitment')
if commitment is not None:
    commitment = float(commitment)
    if commitment < 0:
        commitment = abs(commitment)  # only if magnitude is known-correct
Fund(..., commitment=commitment)

Type guard

def is_valid_commitment(c) -> bool:
    return c is None or float(c) >= 0

Prevention

When it happens

Trigger: Fund(..., commitment=-50_000_000) from a data feed that encodes withdrawals as negative commitments, or a sign error in unit conversion (e.g. subtracting instead of adding adjustments).

Common situations: Reusing P&L/cash-flow sign conventions for a size field; importing from accounting systems where debits are negative; arithmetic bugs in normalization pipelines that flip the sign.

Related errors


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