HKUDS/Vibe-Trading · error · ValueError
contribution on {flow.date} is after as_of={measurement}; a
Error message
contribution on {flow.date} is after as_of={measurement}; a preferred return cannot accrue backwards What it means
Preferred return accrues forward from each contribution date to the measurement date; a contribution dated after as_of would imply negative accrual time, which the function refuses rather than returning a negative hurdle.
Source
Thrown at agent/src/quantlib/fundmath.py:984
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:
years = (measurement - flow.date).days / days_per_year
if years < 0.0:
raise ValueError(
f"contribution on {flow.date} is after as_of={measurement}; a "
"preferred return cannot accrue backwards"
)
principal = -flow.amount
if compounding == "compound":
total += principal * ((1.0 + rate) ** years - 1.0)
else:
total += principal * rate * years
return total
@dataclass(frozen=True)
class WaterfallTier:
"""One tier of a distribution waterfall and how it split.
Attributes:
name: Tier label, one of the ``TIER_*`` constants.
amount: Dollars that flowed through this tier.View on GitHub (pinned to 80ffdda44c)
Solutions
- Move as_of to on or after the latest contribution date (e.g. the latest mark date via _default_as_of semantics)
- Fix misparsed dates (day/month swap) in the contribution records
Example fix
# before preferred_return_amount(series, rate=0.08, as_of="2024-01-01") # draw on 2024-06-30 # after preferred_return_amount(series, rate=0.08, as_of="2024-12-31")
Defensive patterns
Strategy: validation
Validate before calling
last_contrib = max(f.date for f in series.filter(kind=CONTRIB_KINDS))
if as_of is None:
as_of = max(last_contrib, *series.dates())
else:
assert as_of >= last_contrib, f"as_of {as_of} predates draw {last_contrib}" Prevention
- Parse dates with explicit formats to avoid day/month swaps
- Derive as_of from the data rather than hardcoding
When it happens
Trigger: Calling preferred_return_amount(series, rate=0.08, as_of=date(2024,1,1)) when the series contains a contribution dated 2024-06-30 — i.e. as_of predates a draw.
Common situations: Measuring 'as of' a quarter-end that precedes a later capital call; date parsing that swaps day/month producing future dates; stale as_of defaults.
Related errors
- preferred rate must be non-negative, got {rate!r}
- compounding={compounding!r} is not one of {PREFERRED_COMPOUN
- as_of is required for an empty series
- latest valuation on {marks[-1].date} is {value!r}; a residua
- paid-in capital is {paid_in!r}; a capital multiple is undefi
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/12b1061c73d61edd.
Report an issue: GitHub.