HKUDS/Vibe-Trading · error · ValueError
spot_points must be between {_MIN_SPOT_POINTS} and {_MAX_SPO
Error message
spot_points must be between {_MIN_SPOT_POINTS} and {_MAX_SPOT_POINTS} What it means
Thrown by _spot_points when the integer grid size falls outside [_MIN_SPOT_POINTS, _MAX_SPOT_POINTS]. The bounds cap chart resolution to keep output payload and compute bounded; values like 1 or 100000 are rejected.
Source
Thrown at agent/src/tools/options_payoff_tool.py:299
raise ValueError(f"{name} must be finite")
return value
def _spot_points(raw: Any) -> int:
"""Validate the bounded display-grid size."""
if raw is None or raw == "":
return _DEFAULT_SPOT_POINTS
if isinstance(raw, bool):
raise ValueError("spot_points must be an integer")
try:
numeric = float(raw)
except (TypeError, ValueError, OverflowError) as exc:
raise ValueError("spot_points must be an integer") from exc
if not math.isfinite(numeric) or not numeric.is_integer():
raise ValueError("spot_points must be an integer")
points = int(numeric)
if not _MIN_SPOT_POINTS <= points <= _MAX_SPOT_POINTS:
raise ValueError(f"spot_points must be between {_MIN_SPOT_POINTS} and {_MAX_SPOT_POINTS}")
return points
def _spot_bounds(kwargs: dict[str, Any], legs: list[OptionLeg], entry_spot: float) -> tuple[float, float]:
"""Resolve explicit chart bounds or safe defaults covering every strike."""
reference = [entry_spot, *(leg.strike for leg in legs)]
default_min = max(min(reference) * 0.5, 0.0)
default_max = max(reference) * 1.5
spot_min = _optional_float(kwargs, "spot_min", default_min)
spot_max = _optional_float(kwargs, "spot_max", default_max)
if spot_min < 0:
raise ValueError("spot_min must be non-negative")
if spot_max <= spot_min:
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:View on GitHub (pinned to 80ffdda44c)
Solutions
- Clamp to the allowed range: max(_MIN_SPOT_POINTS, min(_MAX_SPOT_POINTS, n))
- Read the constants at the top of options_payoff_tool.py to know the exact bounds
- Omit spot_points entirely to use the curated default
Example fix
// before
execute({..., "spot_points": 5000})
// after
execute({..., "spot_points": min(5000, _MAX_SPOT_POINTS)}) Defensive patterns
Strategy: validation
Validate before calling
from agent.src.tools.options_payoff_tool import _MIN_SPOT_POINTS, _MAX_SPOT_POINTS
n = kwargs.get("spot_points")
if n is not None:
kwargs["spot_points"] = max(_MIN_SPOT_POINTS, min(_MAX_SPOT_POINTS, int(n))) Type guard
def spot_points_in_range(n: int) -> bool:
return _MIN_SPOT_POINTS <= n <= _MAX_SPOT_POINTS Try / catch
try:
execute(kwargs)
except ValueError as e:
if "between" in str(e):
kwargs["spot_points"] = None; execute(kwargs) # use default Prevention
- Clamp user resolution requests client-side
- Read module constants instead of guessing limits
- Default to omitting spot_points
When it happens
Trigger: spot_points=3 (too coarse) or spot_points=5000 (too fine), after passing the integer checks.
Common situations: High-DPI chart requests; users asking for 'max resolution'; tiny test values; defaults from a different tool version drifting outside the range.
Related errors
- legs may contain at most {_MAX_LEGS} entries
- scenario_iv_values may contain at most {_MAX_IV_SCENARIOS} e
- 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/a5b21cfc22ce42d2.
Report an issue: GitHub.