European vanilla option pricing with C++.- Part 1

European vanilla option pricing with C++ and analytic formulae.

In this article we will price a European vanilla option via the correct analytic solution of the Black-Scholes equation. We won’t be concentrating on an extremely efficient or optimised implementation at this stage. Right now I just want to show you how the mathematical formulae correspond to the C++ code.

Black-Scholes Analytic Pricing Formula.

The first stage in implementation is to briefly discuss the Black-Scholes analytic solution for the price of a vanilla call or put option. Consider the price of a European Vanilla Call, C(S,t). S is the underlying asset price, K is the strike price, r is the interest rate (or the “risk-free rate”), T is the time to maturity and σ is the (constant) volatility of the underlying asset S. N is a function which will be described in detail below. The analytical formula for C(S,t) is given by:

[ begin{eqnarray*} C(S,t) = SN(d_1) – Ke^{-rT} N(d_2) end{eqnarray*} ]

With d1 and d2 defined as follows:

[ begin{eqnarray*} d_1 &=& frac{log(S/K) + (r+frac{sigma^2}{2})T}{sigma sqrt{T} }\ d_2 &=& d_1 – sigma sqrt{T} end{eqnarray*} ]

Making use of put-call parity, we can also price a European vanilla put, P(S,t), with the following formula:

[ P ( S , t ) = K e − r T − S + C ( S , t ) = K e − r T − S + ( S N ( d 1 ) − K e − r T N ( d 2 ) ) ]

All that remains is to describe the function N, which is the cumulative distribution function of the standard normal distribution. The formula for N is given by:

[ begin{eqnarray*} N(x) = frac{1}{sqrt{2 pi}} int^x_{-infty} e^{-t^{2} /2} dt end{eqnarray*} ]

It would also help to have closed form solutions for the “Greeks”. These are the sensitivities of the option price to the various underlying parameters. In order to calculate these sensitivities we need the formula for the probability density function of the standard normal distribution which is given below:

[ begin{eqnarray*} f(x) = frac{1}{sqrt{2 pi}} e^{-x^{2}/2} end{eqnarray*} ]

Note that we won’t be computing the “Greeks” in this article, we will leave them for later, but I wanted you to be aware of the statistical formulae which are necessary.

Publicado por djalmabina

WordPress and Google Maps developer,Blogger, Article Writer,Freelance Writer. Please look my recent Blogs:

%d blogueiros gostam disto: