HKUDS/Vibe-Trading · error · ValueError

strike is required

Error message

strike is required

What it means

Second mandatory check in options pricing execute: after spot passes, strike must be present and non-null. Same envelope-wrapped ValueError pattern.

Source

Thrown at agent/src/tools/options_pricing_tool.py:112

    def execute(self, **kwargs: Any) -> str:
        """Run options pricing calculation.

        Args:
            **kwargs: Must include spot, strike, expiry_days, volatility, option_type.
                     Optional risk_free_rate.

        Returns:
            JSON string containing price, delta, gamma, theta, vega, or an error
            envelope when an argument is missing or cannot be read as a number.
            ``risk_free_rate`` is optional and defaults to its schema value 0.05,
            so an explicit JSON ``null`` is treated as omission.
        """
        try:
            if "spot" not in kwargs or kwargs["spot"] is None:
                raise ValueError("spot is required")
            if "strike" not in kwargs or kwargs["strike"] is None:
                raise ValueError("strike is required")
            if "expiry_days" not in kwargs or kwargs["expiry_days"] is None:
                raise ValueError("expiry_days is required")
            if "volatility" not in kwargs or kwargs["volatility"] is None:
                raise ValueError("volatility is required")
            spot = float(kwargs["spot"])
            strike = float(kwargs["strike"])
            expiry_days = float(kwargs["expiry_days"])
            r_val = kwargs.get("risk_free_rate")
            r = float(r_val if r_val is not None and r_val != "" else 0.05)
            sigma = float(kwargs["volatility"])
            option_type = str(kwargs.get("option_type") or "")
        except (TypeError, ValueError, KeyError, OverflowError) as exc:
            # OverflowError: a JSON integer larger than a float (e.g. 10**10000)
            # raises it from float(), and it must not escape this envelope.
            return json.dumps(
                {"status": "error", "tool": "options_pricing", "error": f"invalid or missing input argument: {exc}"},
                ensure_ascii=False,
            )

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Pass a numeric strike, e.g. strike: 105.0
  2. Validate all four required keys (spot, strike, expiry_days, volatility) before invoking

Example fix

// before
tool.execute(spot=100, expiry_days=30, volatility=0.2)
// after
tool.execute(spot=100, strike=105, expiry_days=30, volatility=0.2)
Defensive patterns

Strategy: validation

Validate before calling

required = ("spot", "strike", "expiry_days", "volatility")
missing = [k for k in required if kwargs.get(k) is None]
if missing:
    raise ArgumentError(f"missing: {missing}")

Type guard

def has_required_pricing_args(kw: dict) -> bool:
    return all(kw.get(k) is not None for k in ("spot", "strike", "expiry_days", "volatility"))

Try / catch

try:
    out = tool.execute(**kwargs)
except ValueError as e:
    if "strike is required" in str(e):
        return error_envelope("Please supply the strike price.")

Prevention

When it happens

Trigger: Calling execute with spot supplied but strike missing or null. Note spot's error fires first if spot is also missing.

Common situations: Building kwargs dynamically and forgetting strike, or LLM omitting it when the user only mentioned spot.

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


AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28). Data as JSON: /api/errors/9d43c40299acb7eb. Report an issue: GitHub.