HKUDS/Vibe-Trading · error · ValueError

vintage_year={self.vintage_year!r} is outside the plausible

Error message

vintage_year={self.vintage_year!r} is outside the plausible range 1800-2200

What it means

Fund.__post_init__ range-checks vintage_year, when provided, against 1800–2200 to catch unit and encoding errors (e.g. a year stored as 20,250 or 105). vintage_year may be None, but a non-None value outside the band is rejected.

Source

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

    def __post_init__(self) -> None:
        """Validate the base fields plus fund-specific ranges.

        Raises:
            ValueError: If ``structure`` is unknown, ``commitment`` is
                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)

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Fix the source value to a plausible 4-digit year
  2. If two-digit years appear, expand them: 2000 + yy for yy < 100 (with a cutoff heuristic)
  3. Validate/clip vintage_year at ingest and flag outliers before constructing Fund objects

Example fix

# before
Fund(instrument_id='f1', vintage_year=20250)

# after
Fund(instrument_id='f1', vintage_year=2025)
Defensive patterns

Strategy: validation

Validate before calling

vy = row.get('vintage_year')
if vy is not None:
    vy = int(vy)
    if not 1800 <= vy <= 2200:
        raise ValueError(f'implausible vintage_year {vy} on row {row_id}')
fund = Fund(..., vintage_year=vy)

Type guard

def is_plausible_vintage_year(y) -> bool:
    return y is None or (isinstance(y, int) and 1800 <= y <= 2200)

Prevention

When it happens

Trigger: Fund(..., vintage_year=20250) (typo/extra digit), vintage_year=25 (two-digit year), or vintage_year=105 (Excel serial or misparsed date). The value is int()-coerced before comparison, so '2024' as a string is fine but 20240 is not.

Common situations: Importing from Excel where the year column was parsed as a full date serial or truncated; hand-typed data entry errors; years accidentally multiplied or concatenated (e.g. 20242025).

Related errors


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