HKUDS/Vibe-Trading · error · ValueError
as_of is required for an empty series
Error message
as_of is required for an empty series
What it means
When as_of is omitted, preferred_return_amount measures at the latest flow date, which is impossible for an empty series, so an explicit as_of is mandatory in that case.
Source
Thrown at agent/src/quantlib/fundmath.py:975
for an empty series.
"""
_require_series(series)
if rate < 0.0:
raise ValueError(f"preferred rate must be non-negative, got {rate!r}")
if compounding not in PREFERRED_COMPOUNDING:
raise ValueError(
f"compounding={compounding!r} is not one of {PREFERRED_COMPOUNDING}"
)
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 totalView on GitHub (pinned to 80ffdda44c)
Solutions
- Pass an explicit as_of date, e.g. as_of="2024-12-31"
- Skip empty series in batch jobs before calling
Example fix
# before preferred_return_amount(empty_series, rate=0.08) # after preferred_return_amount(empty_series, rate=0.08, as_of="2024-12-31")
Defensive patterns
Strategy: validation
Validate before calling
if series.is_empty and as_of is None:
as_of = period_end_date # supply explicit measurement date Prevention
- Always pass as_of explicitly in batch pipelines
- Skip empty series early
When it happens
Trigger: Calling preferred_return_amount on an empty CashFlowSeries with as_of=None (the default).
Common situations: Running the calculation over a batch of funds where some have no contributions yet; filters that removed all flows before the call.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- preferred rate must be non-negative, got {rate!r}
- compounding={compounding!r} is not one of {PREFERRED_COMPOUN
- contribution on {flow.date} is after as_of={measurement}; a
- 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/6b37b42610e2f5b1.
Report an issue: GitHub.