HKUDS/Vibe-Trading · error · ValueError
scenario_iv_values may contain at most {_MAX_IV_SCENARIOS} e
Error message
scenario_iv_values may contain at most {_MAX_IV_SCENARIOS} entries What it means
Thrown by _scenario_ivs when the supplied scenario_iv_values list exceeds _MAX_IV_SCENARIOS entries. The cap keeps the scenario matrix output bounded; it fires after the non-empty array check and before numeric conversion.
Source
Thrown at agent/src/tools/options_payoff_tool.py:331
raise ValueError("spot_max must be greater than spot_min")
return spot_min, spot_max
def _scenario_ivs(raw: Any, entry_iv: float) -> np.ndarray:
"""Resolve bounded explicit IV scenarios or the skill's five defaults."""
if raw is None:
values = [
entry_iv * 0.5,
entry_iv * 0.75,
entry_iv,
entry_iv * 1.25,
entry_iv * 1.5,
]
else:
if not isinstance(raw, list) or not raw:
raise ValueError("scenario_iv_values must be a non-empty array")
if len(raw) > _MAX_IV_SCENARIOS:
raise ValueError(f"scenario_iv_values may contain at most {_MAX_IV_SCENARIOS} entries")
try:
values = [float(value) for value in raw]
except (TypeError, ValueError, OverflowError) as exc:
raise ValueError("scenario_iv_values must contain numbers") from exc
array = np.asarray(values, dtype=float)
if not np.isfinite(array).all() or (array <= 0).any():
raise ValueError("scenario_iv_values must contain positive finite values")
return array
def _rounded(value: float) -> float:
"""Round a finite scalar for stable, compact JSON."""
return round(float(value), 6)
def _rounded_array(values: np.ndarray) -> list[float]:
"""Round a numeric array for stable, compact JSON."""
return [round(float(value), 6) for value in np.asarray(values).tolist()]View on GitHub (pinned to 80ffdda44c)
Solutions
- Downsample to at most _MAX_IV_SCENARIOS representative IVs
- Pick key scenarios: [0.5, 0.75, 1.0, 1.25, 1.5] * entry_iv
- Check the constant at the top of options_payoff_tool.py for the exact cap
Example fix
// before
execute({..., "scenario_iv_values": np.linspace(0.1, 0.9, 50).tolist()})
// after
execute({..., "scenario_iv_values": [0.15, 0.20, 0.25, 0.30, 0.35]}) Defensive patterns
Strategy: validation
Validate before calling
from agent.src.tools.options_payoff_tool import _MAX_IV_SCENARIOS
ivs = kwargs.get("scenario_iv_values")
if ivs and len(ivs) > _MAX_IV_SCENARIOS:
step = len(ivs) / _MAX_IV_SCENARIOS
kwargs["scenario_iv_values"] = [ivs[int(i*step)] for i in range(_MAX_IV_SCENARIOS)] Type guard
def iv_count_ok(ivs) -> bool:
return ivs is None or 0 < len(ivs) <= _MAX_IV_SCENARIOS Try / catch
try:
execute(kwargs)
except ValueError as e:
if "at most" in str(e) and "scenario_iv" in str(e):
downsample_and_retry(kwargs) Prevention
- Don't reuse dense plotting grids as scenario inputs
- Pick 3-5 representative IV levels
- Read _MAX_IV_SCENARIOS from the module
When it happens
Trigger: Passing a finely grained IV grid (e.g. np.linspace(0.1, 0.9, 50).tolist()) as scenario values.
Common situations: Reusing plotting grids as scenario inputs; sensitivity-sweep scripts; LLMs over-generating scenario lists.
Related errors
- legs may contain at most {_MAX_LEGS} entries
- spot_points must be between {_MIN_SPOT_POINTS} and {_MAX_SPO
- T must be > 0 to imply a volatility, got {T}
- valuations may contain at most {_MAX_VALUATIONS} entries
- legs must be a non-empty array
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/cb73bb6a534fb06d.
Report an issue: GitHub.