black-scholes-pricer
v2.1.3
Published
European option pricing and Greeks under the Black-Scholes-Merton model.
Downloads
130
Maintainers
Readme
black-scholes-pricer
European option pricing and Greeks under the Black-Scholes-Merton model. No dependencies, plain CommonJS.
Supports a continuous dividend yield q (the Merton extension), the standard
Greeks, and an implied-volatility solver.
Install
npm install black-scholes-pricerUsage
const { callPrice, putPrice, greeks, impliedVol } = require('black-scholes-pricer');
// S, K, t (years), r, sigma, [q]
callPrice(100, 100, 1, 0.05, 0.2); // ~10.4506
putPrice(100, 95, 0.75, 0.03, 0.25);
const g = greeks('call', 100, 100, 1, 0.05, 0.2);
// { delta, gamma, vega, theta, rho }
impliedVol('call', 10.45, 100, 100, 1, 0.05); // ~0.20Notes on units
sigmaandrare decimals (0.2 = 20%).thetais per year; divide by 365 for per-day.vegaandrhoare per unit move; multiply by 0.01 for the familiar "per 1 point" market quote.- When
t <= 0orsigma <= 0, prices fall back to discounted intrinsic value.
The normal CDF uses the Abramowitz & Stegun 7.1.26 rational approximation of
erf (absolute error ~1.5e-7), which is plenty for pricing but not intended
for tail-probability work.
License
ISC
