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.
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 argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- compounding= is not one of
- contribution on is after as_of= ; a preferred return cannot…
- preferred rate must be non-negative, got
- carry_rate must be in
- catch_up_rate= must exceed carry_rate= , otherwise the…
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/6b37b42610e2f5b1.
Report an issue: GitHub.
Appendix: 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)