Speed

The Two Numbers d1 and d2

The Black-Scholes formula is built from d1 and d2, which measure in standard deviations how far the strike lies from where the model expects the price to be; compute both by hand and by the engine.

The question

The closed form of the last lesson is made of two numbers, called d1 and d2. What do they measure, and how are they computed from the spot, the strike, the rate, the volatility and the years?

In the pricing model, where the stock grows at the risk-free rate (the name of a model input), the logarithm of the price at the end of the option's life is normally distributed. Its standard deviation is the volatility times the square root of the years. d2 says how many of those standard deviations separate the strike from the centre of that distribution, and d1 is d2 plus one such standard deviation.

Work it by hand

Use the lesson's example: spot 100, strike 105, rate 0.05, volatility 0.2, one year. The standard deviation of the log price is 0.2 times the square root of 1, which is 0.2.

d1 is (ln(100 / 105) + (0.05 + 0.2 squared / 2) times 1) divided by 0.2. The log is -0.0487902 and the second term is 0.07, so d1 is 0.0212098 divided by 0.2, which is 0.106049.

d2 is d1 minus 0.2, which is -0.093951. The minus sign says that the log of the strike lies 0.093951 standard deviations above the centre of the model's distribution of the end log price.

Run it

The program computes d1 and d2 by the formula and asks the engine for both with pricing.bs_d1 and pricing.bs_d2. Line 4 is the standard deviation of the log price. Line 5 is d1 by the formula, with lmf.log for the natural logarithm, and line 6 is d2. Lines 10 and 11 read them from the engine, and the picture shows all of them rounded to six decimals.

The standard deviation 0.2, d1 0.106049 by hand and by the engine, and d2 -0.093951 by hand and by the engine.
let m = model.black_scholes(spot, rate, 0.0, vol);
let call = instrument.european_call(strike, float(years));
let t = float(years);
let sd = vol * sqrt(t);
let d1 = (lmf.log(spot / strike) + (rate + vol * vol / 2.0) * t) / sd;
let d2 = d1 - sd;
lmcode_return_put("sd", lmf.round(sd, 6));
lmcode_return_put("d1_hand", lmf.round(d1, 6));
lmcode_return_put("d2_hand", lmf.round(d2, 6));
lmcode_return_put("d1_engine", lmf.round(pricing.bs_d1(call, m), 6));
lmcode_return_put("d2_engine", lmf.round(pricing.bs_d2(call, m), 6));
let answer = int(math_round(lmf.round(d1, 6) * 1000000.0));
{
  "answer": 106049,
  "sd": 0.2,
  "d1_hand": 0.106049,
  "d2_hand": -0.093951,
  "d1_engine": 0.106049,
  "d2_engine": -0.093951
}

The two routes agree to the last digit shown. Line 12 returns d1 in millionths, because binary floats rarely give a textbook value.

You can change the four inputs and the years, a whole number of 1 or more. A volatility of 0 or a spot of 0 stops line 1, a strike of 0 or 0 years stops line 2, each with the engine's message: "model.black_scholes: volatility must be positive", "model.black_scholes: spot must be positive", "option strike must be positive", "option maturity must be positive".

Your turn

For which strike is d2 exactly zero? The program below is meant to return that strike, in whole cents, for spot, rate, vol and years. Decide whether it does, and find the candidates that do. Check runs each candidate on the data shown and on four others.

The inputs spot 80, rate 0.03, volatility 0.25 and 4 years, and the number 9020, the cents that the shown program returns.
let t = float(years);
let strike = spot * lmf.exp(rate * t);
let answer = int(math_round(lmf.round(strike, 2) * 100.0));
{
  "answer": 9020
}

Return, in whole cents, the strike at which d2 of the call is exactly zero, for the spot, the rate, the volatility and the years, with no dividend. The strike is rounded to cents.

Read the result carefully

d1 and d2 are bookkeeping of the model. They exist because the model assumes that the log of the price is normal with a constant volatility, and they are not quantities anyone observes. A strike with d2 at zero is not a special price in any market: it is where this model puts the centre of its own distribution.

The inputs are made-up numbers, and the page does not say that the model's centre is where a price will be. It describes a model and is not investment advice.

Recap

  • d2 is the distance from the log of the strike to the model's centre of the log price, in standard deviations of volatility times the square root of the years.
  • d1 is d2 plus volatility times the square root of the years.
  • The engine's pricing.bs_d1 and pricing.bs_d2 agree with the formula.
  • d2 is zero when the log of the strike sits at the model's centre of the log price.