Skip to content
All library documents

Black-Scholes Call and Put Pricing with a Normal CDF Approximation

Article Quant Q&A · Author: leonardorame

Summary

The document presents a Delphi implementation of the Black-Scholes formula for European call and put options. It calculates the standard d1 and d2 terms from spot price, strike, time to expiration, interest rate, and volatility, then applies the cumulative standard normal distribution to obtain a theoretical option value. The call and put branches use the discounted strike and underlying price in the familiar pricing expressions.

The implementation approximates the normal cumulative distribution with a polynomial expression, using fixed coefficients and the absolute value of the input before adjusting the result for negative values. The author notes that its output differs from another online calculator and asks for an alternative implementation, but the document provides no comparison details or validation cases. Accurate results therefore depend on consistent input conventions, units, and numerical approximation; the snippet alone does not establish why the referenced outputs disagree.

Key ideas

  • Black-Scholes call and put values are calculated from spot, strike, time, rate, and volatility inputs.
  • The pricing equations use d1 and d2 together with cumulative normal probabilities.
  • The displayed implementation approximates the standard normal cumulative distribution with a polynomial formula.
  • Differences between implementations can arise from input conventions or numerical methods, but the document does not diagnose its discrepancy.

Tags

Full text
# Black-Scholes in Delphi


# Black-Scholes in Delphi












when trying to implement the Black-Scholes formula in Delphi, I've found this: http://www.espenhaug.com/black_scholes.html

I've checked the results against option-price.com and found they are different. Can anyone share the code for the B&S formula in Delphi/FreePascal (from a different source than espenhaug.com?.

```
{Black and Scholes (1973) Stock options}

function BlackScholes(CallPutFlag : string; S, X, T, r, v : Double): Double;
var
  d1, d2 : Double;

begin
  Result := 0;
  d1 := (LN(S / X) + (r + Power(v, 2) / 2) * T) / (v * SqRt(T));
  d2 := d1 - v * SqRt(T);
  if CallPutFlag = 'c' then
    Result := S * CND(d1) - X * Exp(-r * T) * CND(d2)
  else
    if CallPutFlag = 'p' then
      Result := X * Exp(-r * T) * CND(-d2) - S * CND(-d1);
end;

{The cumulative normal distribution function}
function CND(X : Double) : Double;
var
  L, K : Double;

const
  a1 = 0.31938153;   a2 = -0.356563782;  a3 = 1.781477937;
  a4 = -1.821255978; a5 = 1.330274429;

begin
  L := Abs(X);
  K := 1 / (1 + 0.2316419 * L);
  Result := 1 - 1 / SqRt(2 * Pi) * Exp(-Power(L, 2) / 2)
            * (a1 * K + a2 * Power(K, 2) + a3 * Power(K, 3)
            + a4 * Power(K, 4) + a5 * Power(K, 5));
  if X < 0 then
    Result := (1 - Result)
end;
```

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.