Draft:The COS method

The COS method is a numerical technique in computational finance to efficiently price European plain vanilla put and call options provided the characteristic function of the logarithmic returns is given in closed-form. The main idea of the COS method is to approximate the (usually unknown) probability density function of the logarithmic returns by a cosine series expansion. The method has been developed in 2008 by Fang Fang and Cornelis W. Oosterlee. The COS method converges for a large family of densities. The COS method converges exponentially if the density of the logarithmic returns is smooth and has semi-heavy tails.

= Introduction =

Consider a financial market with a bank-account paying a risk-free rate $r$ and stock with deterministic price $S_{0}>0$  today and random price $S_{T}$  at some future date $T>0$. Let $\mu$ be the expectation of $\log(S_{T})$  under the risk-neutral measure and assume the characteristic function $\varphi$  of the centralized log-returns $X:=\log(S_{T})-\mu$  is given in closed-form. The characteristic function $\varphi$ is given explicitly for many models and processes, e.g., the Black-Scholes model, the variance gamma process, the CGMY model or the Heston model. The price of a European put option with maturity $T>0$ and strike $K>0$  is given by the fundamental theorem of asset pricing by $$\int_{\mathbb{R}}e^{-rT}\max\left(K-e^{x+\mu},0\right)f(x)dx,$$ where $f$  is the probability density function of $X$. The price of a call option can be obtained by the put-call parity. Very often, $f$ is not given explicitly and the COS method is used to approximate $f$  and the price of the option.

= The method =

For some $L>0$, the density $f$ is truncated and the truncated density is approximated by a cosine series expansion: $$f(x)\approx\frac{c_{0}}{2}+\sum_{k=1}^{N}c_{k}\cos\left(k\pi\frac{x+L}{2L}\right),\quad x\in[-L,L],$$ where for $k=0,1,...,N$  the coefficients $c_{k}$  are defined by $$\begin{aligned} c_{k}:=\frac{1}{L}\int_{\mathbb{R}}f(x)\cos\big(k\pi\frac{x+L}{2L}\big)dx= & \frac{1}{L}\Re\bigg\{\varphi\bigg(\frac{k\pi}{2L}\bigg)e^{i\frac{k\pi}{2}}\bigg\}.\end{aligned}$$ $\Re(z)$ denotes the real part of a complex number $z$  and $i=\sqrt{-1}$  is the imaginary unit. The price of a European put option can be approximated by $$\int_{\mathbb{R}}e^{-rT}\max\left(K-e^{x+\mu},0\right)f(x)dx\approx\frac{c_{0}v_{0}}{2}+\sum_{k=1}^{N}c_{k}v_{k},$$ where $$\begin{aligned} v_{k} & :=\int_{-L}^{L}e^{-rT}\max\left(K-e^{x+\mu},0\right)\cos\big(k\pi\frac{x+L}{2L}\big)dx.\end{aligned}$$ The coefficients $c_{k}$ are given in closed-form provided $\varphi$  is given analytically and the coefficients $v_{k}$  can also be computed explicitly in important cases, e.g., for plain vanilla European put or call options and digital options. This makes the COS method numerically very efficient and robust.

Let $d:=\min\left(\log\left(K\right)-\mu,L\right)$. For a European put option it holds that $v_{k}=0$ if $d\leq-L$  and otherwise $$v_{k}=e^{-rT}\left(K\Psi_{0}(k)-e^{\mu}\Psi_{1}(k)\right)$$ where

$$\Psi_{0}(k)=\begin{cases} d+L & ,k=0\\ \frac{2L}{k\pi}\sin\big(k\pi\dfrac{d+L}{2L}\big) & ,k>0 \end{cases}$$ and $$\begin{aligned} \Psi_{1}(k) & =\frac{e^{d}\left(\frac{k\pi}{2L}\sin\left(k\pi\frac{d+L}{2L}\right)+\cos\left(k\pi\frac{d+L}{2L}\right)\right)-e^{-L}}{1+\left(\frac{k\pi}{2L}\right)^{2}},\quad k\geq0.\end{aligned}$$ To price a call option it is numerically more stable to price a put option instead and use the put-call parity.

= Parameters =

To apply the COS method, one has to specify the truncation range $[-L,L]$ and the number of terms $N$. Let $\varepsilon$ be the error tolerance between the true price and its approximation by the COS method. If $\varepsilon$ is small enough and $f$  has semi-heavy tails, the truncation range of a put option can be chosen using Markov’s inequality by  $$L=\left(\frac{2Ke^{-rT}\mu_{n}}{\varepsilon}\right)^{\frac{1}{n}},$$ where $n\in\mathbb{N}$  is even and $\mu_{n}$  is the $n$ -th moment of $X$, which can be obtained using a computer algebra system and the following relation of $\mu_{n}$  and the characteristic function: $$\mu_{n}=\frac{1}{i^{n}}\left.\frac{\partial^{n}}{\partial u^{n}}\varphi(u)\right|_{u=0}.$$ Often, $n\in\{4,6,8\}$  is a reasonable choice. In particular, the fourth moment can also be obtained by the Kurtosis and variance of $X$ by $\mu_{4}=\text{Kurt}(X)\left(\text{Var}(X)\right)^{2}$.

If $f$ is also a $s+1\in\mathbb{N}$  times differentiable function with bounded derivatives, the number of terms can then be chosen using integration by parts by $$N\geq\left(\frac{2^{s+\frac{5}{2}}\left\Vert f^{(s+1)}\right\Vert _{\infty}L^{s+2}}{s\pi^{s+1}}\frac{12Ke^{-rT}}{\varepsilon}\right)^{\frac{1}{s}}.$$ $\|.\|_{\infty}$  denotes the uniform norm. There is the following useful inequality: $$\|f^{(s+1)}\|_{\infty}\leq\frac{1}{2\pi}\int_{\mathbb{R}}|u|^{s+1}|\varphi(u)|du.$$ The last integral can be solved numerically with standard techniques and it is also given explicitly in some cases.

= Black-Scholes model =

In the Black-Scholes model with volatility $\sigma>0$, the stock price is modelled at maturity $T>0$ by $$S_{T}=S_{0}e^{rT-\frac{1}{2}\sigma^{2}T+\sigma\sqrt{T}Z},$$ where $Z$  is a standard normal random variable. The expectation of $\log(S_{T})$ under the risk-neutral measure is given by $$\mu=\log(S_{0})+rT-\frac{1}{2}\sigma^{2}T$$ and the characteristic function of $X=\log(S_{T})-\mu$  is given by $$\varphi(u)=e^{-\frac{\sigma^{2}T}{2}u^{2}},\quad u\in\mathbb{R},$$ since $X$  follows a normal distribution. The $n$ -th moment of $X$ for even $n$  in the Black-Scholes model is given by $$\mu_{n}=(\sigma\sqrt{T})^{n}\left((n-1)(n-3)(n-5)\cdot\cdot\cdot3\cdot1\right).$$ The derivative $f^{(s+1)}$  of the probability density function of $X$  is bounded by $$\|f^{(s+1)}\|_{\infty}\leq\frac{\Gamma\left(\frac{s}{2}+1\right)2^{\frac{s}{2}}}{\pi(\sigma\sqrt{T})^{s+2}},$$ where $\Gamma$  is the Gamma function.

= Simple implementation =

In the following code, the COS method is implemented in R for the Black-Scholes model to price European call option and the Heston model to price a put option.

= See also =
 * Carr–Madan formula