API: options.js
Pricing, Greeks, surface and solver.
Import path site/options.js. Pure arithmetic, no imports, safe in any runtime.
Pricing
- price(o)
{S, K, T, r, q, sigma, kind}to a number. Returns discounted forward intrinsic for degenerateTorsigma. Throws ifSorKis not positive.- greeks(o)
- Same arguments, returns
{delta, gamma, vega, theta, rho}in desk units. - probITM(o)
- Risk neutral probability of finishing in the money.
Distribution
- ncdf(x)
- Standard normal CDF, Hart and West, about 1e−15 accurate.
- npdf(x)
- Standard normal density.
Surface and solver
- surfaceVol(o)
{S, K, T, atmVol, skew, curve, termSlope}to a volatility, clamped to [0.02, 4].- impliedVol(o)
- Newton with bisection fallback. Returns
nulloutside no arbitrage bounds or where vega is below the identifiability threshold. - strikeForDelta(o)
- Inverts delta numerically. One branch serves calls and puts, since delta decreases in strike for both.
- chain(o)
- Prices a list of strikes on the surface, returning prices, Greeks and probabilities.
- strikeLadder(S, n)
- Round strike ladder bracketing spot, shifted up rather than truncated if it would run through zero.