Black Scholes Formula

Overview

The black scholes formula is a formula that solves the black scholes equation for plain vanilla European calls and puts.

The formula for a plain vanilla call is given as

{% C(S_t, t) = N(d_1)S_t - N(d_2)Ke^{-r(T-t)} %}
{% d_1 = \frac{1}{\sigma \sqrt{T-t}} [ln(\frac{S_t}{K}) + (r + \frac{\sigma^2}{2})(T-t)] %}
{% d_2 = d_1 - \sigma \sqrt{T-t} %}
Here, {% C %} is the prices of option, {% S %} is the price of the underlying, {% r %} is the rate of return on cash, {% T-t %} is the time to expiry, and {% \sigma %} is the underlying asset volatility.

{% K %} is the option strike price and N is the cumulative normal distribution with mean 0 and standard deviation of 1. (standard normal)

Black Scholes

The Black Scholes library. encodes the black scholes formula in an easy to use function.

let bs = await import('/code/black-scholes/v1.0.0/black-scholes.mjs'); let price = bs.call(100,100,0.2,0.1,1); //alternatively let price = bs.call({ S:100, K:100, sigma:0.2, r:0.1, t:1 });