Difference between revisions of "Programming/Kdb/Labs/Option pricing"

From Thalesians Wiki
< Programming‎ | Kdb‎ | Labs
Tag: Manual revert
Line 45: Line 45:
\left\{
\left\{
   \begin{array}{ll}
   \begin{array}{ll}
     1 - \phi(x) \left[ c_1 k + c_2 k^2 + c_3 k^3 + c_4 k^4 + c_5 k^5 \right], & \hbox{B,} \\
     1 - \phi(x) \left[ c_1 k + c_2 k^2 + c_3 k^3 + c_4 k^4 + c_5 k^5 \right], & \hbox{if,} \\
     C, & \hbox{D,}
     C, & \hbox{D,}
   \end{array}
   \end{array}

Revision as of 23:15, 17 June 2021

Background: the Black-Scholes formulae

Recall the celebrated Black-Scholes equation

Here

  • is a time in years; we generally use as now;
  • is the value of the option;
  • is the price of the underlying asset at time ;
  • is the volatility — the standard deviation of the asset's returns;
  • is the annualized risk-free interest rate, continuously compounded;
  • is the annualized (continuous) dividend yield.

The solution of this equation depends on the payoff of the option — the terminal condition. In particular, if at the time of expiration, , the payoff is given by , in other words, the option is a European call option, then the value of the option at time is given by the Black-Scholes formula for the European call:

where is the time to maturity, is the forward price, and

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle d_1 = \frac{1}{\sigma\sqrt{\tau}} \left[ \ln\left(\frac{S_t}{K}\right) + \left(r - q + \frac{1}{2}\sigma^2\right)\tau \right] }

and

Here we have used to denote the standard normal cumulative distribution function,

Similarly, if the payoff is given by , in other words, the option is a European put option, then the value of the option at time is given by the Black-Scholes formula for the European put:

We will implement the formulae for the European call and European put in q. However, our first task is to implement .

Task 1: Implementing the standard normal cumulative distribution function

can be approximated by

Failed to parse (unknown function "\begin{array}"): {\displaystyle \left\{ \begin{array}{ll} 1 - \phi(x) \left[ c_1 k + c_2 k^2 + c_3 k^3 + c_4 k^4 + c_5 k^5 \right], & \hbox{x \geq 0,} \\ 1 - N(-x), & \hbox{x < 0,} \end{array} \right. }

where

.