{"record":{"id":"43d4df9a20d18f28","repo":"HKUDS/Vibe-Trading","slug":"expiry-days-is-required","errorCode":null,"errorMessage":"expiry_days is required","messagePattern":"expiry_days is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/tools/options_pricing_tool.py","lineNumber":114,"sourceCode":"        \"\"\"Run options pricing calculation.\n\n        Args:\n            **kwargs: Must include spot, strike, expiry_days, volatility, option_type.\n                     Optional risk_free_rate.\n\n        Returns:\n            JSON string containing price, delta, gamma, theta, vega, or an error\n            envelope when an argument is missing or cannot be read as a number.\n            ``risk_free_rate`` is optional and defaults to its schema value 0.05,\n            so an explicit JSON ``null`` is treated as omission.\n        \"\"\"\n        try:\n            if \"spot\" not in kwargs or kwargs[\"spot\"] is None:\n                raise ValueError(\"spot is required\")\n            if \"strike\" not in kwargs or kwargs[\"strike\"] is None:\n                raise ValueError(\"strike is required\")\n            if \"expiry_days\" not in kwargs or kwargs[\"expiry_days\"] is None:\n                raise ValueError(\"expiry_days is required\")\n            if \"volatility\" not in kwargs or kwargs[\"volatility\"] is None:\n                raise ValueError(\"volatility is required\")\n            spot = float(kwargs[\"spot\"])\n            strike = float(kwargs[\"strike\"])\n            expiry_days = float(kwargs[\"expiry_days\"])\n            r_val = kwargs.get(\"risk_free_rate\")\n            r = float(r_val if r_val is not None and r_val != \"\" else 0.05)\n            sigma = float(kwargs[\"volatility\"])\n            option_type = str(kwargs.get(\"option_type\") or \"\")\n        except (TypeError, ValueError, KeyError, OverflowError) as exc:\n            # OverflowError: a JSON integer larger than a float (e.g. 10**10000)\n            # raises it from float(), and it must not escape this envelope.\n            return json.dumps(\n                {\"status\": \"error\", \"tool\": \"options_pricing\", \"error\": f\"invalid or missing input argument: {exc}\"},\n                ensure_ascii=False,\n            )\n\n        err = _validate_inputs(spot, strike, expiry_days, sigma, r, option_type)","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/tools/options_pricing_tool.py#L96-L132","documentation":"Third mandatory check in options pricing execute: expiry_days must be present and non-null (it is later coerced with float()).","triggerScenarios":"Calling execute with spot and strike supplied but expiry_days absent or null.","commonSituations":"Assuming a default expiry exists (it doesn't; only risk_free_rate defaults), or passing expiry as a date string elsewhere and dropping it here.","solutions":["Pass numeric days to expiry, e.g. expiry_days: 30","If you have a date, compute (expiry_date - today).days first"],"exampleFix":"// before\ntool.execute(spot=100, strike=105, volatility=0.2)\n// after\ntool.execute(spot=100, strike=105, expiry_days=30, volatility=0.2)","handlingStrategy":"validation","validationCode":"required = (\"spot\", \"strike\", \"expiry_days\", \"volatility\")\nmissing = [k for k in required if kwargs.get(k) is None]\nif missing:\n    raise ArgumentError(f\"missing: {missing}\")","typeGuard":"def has_required_pricing_args(kw: dict) -> bool:\n    return all(kw.get(k) is not None for k in (\"spot\", \"strike\", \"expiry_days\", \"volatility\"))","tryCatchPattern":"try:\n    out = tool.execute(**kwargs)\nexcept ValueError as e:\n    if \"expiry_days is required\" in str(e):\n        return error_envelope(\"Please supply days to expiry.\")","preventionTips":["Compute expiry_days from dates before calling","Build kwargs from a fixed template with all four fields","Treat only risk_free_rate as optional"],"tags":["options-pricing","required-argument","missing-parameter"],"backgroundTag":"missing-required-parameter","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}