HKUDS/Vibe-Trading · error · ValueError
maturity_date {self.maturity_date} precedes inception_date {
Error message
maturity_date {self.maturity_date} precedes inception_date {self.inception_date} What it means
Bond.__post_init__ normalizes maturity_date and rejects it when it precedes inception_date, since a bond cannot mature before it is issued. Both dates are normalized (via normalize_date) before the comparison.
Source
Thrown at agent/src/entities/models.py:393
frequency = int(self.coupon_frequency)
if frequency < 0:
raise ValueError(
f"coupon_frequency cannot be negative, got {self.coupon_frequency!r}"
)
if self.coupon_rate and frequency == 0:
raise ValueError(
f"coupon_frequency=0 marks a zero-coupon bond, but coupon_rate="
f"{self.coupon_rate!r} is non-zero"
)
object.__setattr__(self, "coupon_frequency", frequency)
if self.maturity_date is not None:
object.__setattr__(
self,
"maturity_date",
normalize_date(self.maturity_date, field_name="maturity_date"),
)
if self.inception_date is not None and self.maturity_date < self.inception_date:
raise ValueError(
f"maturity_date {self.maturity_date} precedes inception_date "
f"{self.inception_date}"
)
View on GitHub (pinned to 80ffdda44c)
Solutions
- Correct the dates so maturity is on or after inception
- For perpetuities/undated bonds, pass maturity_date=None if supported rather than a placeholder
- Normalize date parsing to ISO format at ingest and cross-check maturity >= inception per row
Example fix
# before Bond(instrument_id='b1', inception_date=date(2025,1,1), maturity_date=date(2024,6,1)) # after Bond(instrument_id='b1', inception_date=date(2024,6,1), maturity_date=date(2025,1,1))
Defensive patterns
Strategy: validation
Validate before calling
from datetime import date
inc = parse_iso(row['inception_date'])
mat = parse_iso(row['maturity_date'])
if mat is not None and inc is not None and mat < inc:
raise ValueError(f'maturity {mat} before inception {inc} on row {row_id}')
Bond(..., inception_date=inc, maturity_date=mat) Type guard
def dates_ordered(inc, mat) -> bool:
return inc is None or mat is None or mat >= inc Prevention
- Parse dates as ISO (YYYY-MM-DD) unambiguously
- Cross-check maturity >= inception during data profiling
- Use None for undated/perpetual instruments instead of sentinel past dates
When it happens
Trigger: Bond(..., inception_date=date(2025,1,1), maturity_date=date(2024,1,1)); also date-format swaps (DD/MM vs MM/DD) that put maturity earlier, or a default far-past maturity (e.g. 1900-01-01) used as a placeholder.
Common situations: Day/month transposition when parsing international date formats; perpetual/undated instruments given a sentinel past date; loading dirty reference data with swapped columns.
Related errors
- face_value must be positive, got {self.face_value!r}
- coupon_rate cannot be negative, got {rate!r}
- coupon_rate must be a decimal fraction (0.05 means 5%), got
- coupon_frequency cannot be negative, got {self.coupon_freque
- coupon_frequency=0 marks a zero-coupon bond, but coupon_rate
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/dec97b6cb1bd1565.
Report an issue: GitHub.