s Chapter Contents
s Chapter Introduction
NAG Library Manual

# NAG Library Function Documentnag_binary_con_price (s30cac)

## 1  Purpose

nag_binary_con_price (s30cac) computes the price of a binary or digital cash-or-nothing option.

## 2  Specification

 #include #include
 void nag_binary_con_price (Nag_OrderType order, Nag_CallPut option, Integer m, Integer n, const double x[], double s, double k, const double t[], double sigma, double r, double q, double p[], NagError *fail)

## 3  Description

nag_binary_con_price (s30cac) computes the price of a binary or digital cash-or-nothing option which pays a fixed amount, $K$, at expiration if the option is in-the-money (see Section 2.4 in the s Chapter Introduction). For a strike price, $X$, underlying asset price, $S$, and time to expiry, $T$, the payoff is therefore $K$, if $S>X$ for a call or $S for a put. Nothing is paid out when this condition is not met.
The price of a call with volatility, $\sigma$, risk-free interest rate, $r$, and annualised dividend yield, $q$, is
 $Pcall = K e-rT Φd2$
and for a put,
 $Pput = K e-rT Φ-d2$
where $\Phi$ is the cumulative Normal distribution function,
 $Φx = 1 2π ∫ -∞ x -y2/2 dy ,$
and
 $d2 = ln S/X + r-q - σ2 / 2 T σ⁢T .$
The option price ${P}_{ij}=P\left(X={X}_{i},T={T}_{j}\right)$ is computed for each strike price in a set ${X}_{i}$, $i=1,2,\dots ,m$, and for each expiry time in a set ${T}_{j}$, $j=1,2,\dots ,n$.

## 4  References

Reiner E and Rubinstein M (1991) Unscrambling the binary code Risk 4

## 5  Arguments

1:    $\mathbf{order}$Nag_OrderTypeInput
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by ${\mathbf{order}}=\mathrm{Nag_RowMajor}$. See Section 2.3.1.3 in How to Use the NAG Library and its Documentation for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or $\mathrm{Nag_ColMajor}$.
2:    $\mathbf{option}$Nag_CallPutInput
On entry: determines whether the option is a call or a put.
${\mathbf{option}}=\mathrm{Nag_Call}$
A call; the holder has a right to buy.
${\mathbf{option}}=\mathrm{Nag_Put}$
A put; the holder has a right to sell.
Constraint: ${\mathbf{option}}=\mathrm{Nag_Call}$ or $\mathrm{Nag_Put}$.
3:    $\mathbf{m}$IntegerInput
On entry: the number of strike prices to be used.
Constraint: ${\mathbf{m}}\ge 1$.
4:    $\mathbf{n}$IntegerInput
On entry: the number of times to expiry to be used.
Constraint: ${\mathbf{n}}\ge 1$.
5:    $\mathbf{x}\left[{\mathbf{m}}\right]$const doubleInput
On entry: ${\mathbf{x}}\left[i-1\right]$ must contain ${X}_{\mathit{i}}$, the $\mathit{i}$th strike price, for $\mathit{i}=1,2,\dots ,{\mathbf{m}}$.
Constraint: ${\mathbf{x}}\left[\mathit{i}-1\right]\ge z\text{​ and ​}{\mathbf{x}}\left[\mathit{i}-1\right]\le 1/z$, where $z={\mathbf{nag_real_safe_small_number}}$, the safe range parameter, for $\mathit{i}=1,2,\dots ,{\mathbf{m}}$.
6:    $\mathbf{s}$doubleInput
On entry: $S$, the price of the underlying asset.
Constraint: ${\mathbf{s}}\ge z\text{​ and ​}{\mathbf{s}}\le 1.0/z$, where $z={\mathbf{nag_real_safe_small_number}}$, the safe range parameter.
7:    $\mathbf{k}$doubleInput
On entry: the amount, $K$, to be paid at expiration if the option is in-the-money, i.e., if ${\mathbf{s}}>{\mathbf{x}}\left[\mathit{i}-1\right]$ when ${\mathbf{option}}=\mathrm{Nag_Call}$, or if ${\mathbf{s}}<{\mathbf{x}}\left[\mathit{i}-1\right]$ when ${\mathbf{option}}=\mathrm{Nag_Put}$, for $\mathit{i}=1,2,\dots ,m$.
Constraint: ${\mathbf{k}}\ge 0.0$.
8:    $\mathbf{t}\left[{\mathbf{n}}\right]$const doubleInput
On entry: ${\mathbf{t}}\left[i-1\right]$ must contain ${T}_{\mathit{i}}$, the $\mathit{i}$th time, in years, to expiry, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
Constraint: ${\mathbf{t}}\left[\mathit{i}-1\right]\ge z$, where $z={\mathbf{nag_real_safe_small_number}}$, the safe range parameter, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
9:    $\mathbf{sigma}$doubleInput
On entry: $\sigma$, the volatility of the underlying asset. Note that a rate of 15% should be entered as 0.15.
Constraint: ${\mathbf{sigma}}>0.0$.
10:  $\mathbf{r}$doubleInput
On entry: $r$, the annual risk-free interest rate, continuously compounded. Note that a rate of 5% should be entered as 0.05.
Constraint: ${\mathbf{r}}\ge 0.0$.
11:  $\mathbf{q}$doubleInput
On entry: $q$, the annual continuous yield rate. Note that a rate of 8% should be entered as 0.08.
Constraint: ${\mathbf{q}}\ge 0.0$.
12:  $\mathbf{p}\left[{\mathbf{m}}×{\mathbf{n}}\right]$doubleOutput
Note: where ${\mathbf{P}}\left(i,j\right)$ appears in this document, it refers to the array element
• ${\mathbf{p}}\left[\left(j-1\right)×{\mathbf{m}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{p}}\left[\left(i-1\right)×{\mathbf{n}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On exit: ${\mathbf{P}}\left(i,j\right)$ contains ${P}_{ij}$, the option price evaluated for the strike price ${{\mathbf{x}}}_{i}$ at expiry ${{\mathbf{t}}}_{j}$ for $i=1,2,\dots ,{\mathbf{m}}$ and $j=1,2,\dots ,{\mathbf{n}}$.
13:  $\mathbf{fail}$NagError *Input/Output
The NAG error argument (see Section 2.7 in How to Use the NAG Library and its Documentation).

## 6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_INT
On entry, ${\mathbf{m}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{m}}\ge 1$.
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 1$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
An unexpected error has been triggered by this function. Please contact NAG.
See Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.
NE_REAL
On entry, ${\mathbf{k}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{k}}\ge 0.0$.
On entry, ${\mathbf{q}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{q}}\ge 0.0$.
On entry, ${\mathbf{r}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{r}}\ge 0.0$.
On entry, ${\mathbf{s}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{s}}\ge 〈\mathit{\text{value}}〉$ and ${\mathbf{s}}\le 〈\mathit{\text{value}}〉$.
On entry, ${\mathbf{sigma}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{sigma}}>0.0$.
NE_REAL_ARRAY
On entry, ${\mathbf{t}}\left[〈\mathit{\text{value}}〉\right]=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{t}}\left[i\right]\ge 〈\mathit{\text{value}}〉$.
On entry, ${\mathbf{x}}\left[〈\mathit{\text{value}}〉\right]=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{x}}\left[i\right]\ge 〈\mathit{\text{value}}〉$ and ${\mathbf{x}}\left[i\right]\le 〈\mathit{\text{value}}〉$.

## 7  Accuracy

The accuracy of the output is dependent on the accuracy of the cumulative Normal distribution function, $\Phi$. This is evaluated using a rational Chebyshev expansion, chosen so that the maximum relative error in the expansion is of the order of the machine precision (see nag_cumul_normal (s15abc) and nag_erfc (s15adc)). An accuracy close to machine precision can generally be expected.

## 8  Parallelism and Performance

nag_binary_con_price (s30cac) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the x06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

None.

## 10  Example

This example computes the price of a cash-or-nothing put with a time to expiry of $0.75$ years, a stock price of $100$ and a strike price of $80$. The risk-free interest rate is $6%$ per year and the volatility is $35%$ per year. If the option is in-the-money at expiration, i.e., if $S>X$, the payoff is $10$.

### 10.1  Program Text

Program Text (s30cace.c)

### 10.2  Program Data

Program Data (s30cace.d)

### 10.3  Program Results

Program Results (s30cace.r)