MATLAB Examples

cf2call

Compute call option prices from characteristic function. Part of the CFH Toolbox.

Syntax

[C K] = CF2CALL(CF)
[C K] = CF2CALL(CF,AUX)

Given a characteristic function CF, returns call option prices C and corresponding strikes K.

Input Arguments

The characteristic function CF should expect the real argument u and return the corresponding characteristic function $\phi(u) = E(\exp(iuX_T))$

AUX is a structure containing optional parameters for the Fourier transform.

  • aux.N denotes the number of points for FRFT evaluation, default 8192
  • aux.uMax is the range of integration of the characteristic function, default 200
  • aux.damp is the damping parameter required by the Carr/Madan approach, default 1.5
  • aux.dx is the discretization of the log strike range, default value 2/N
  • aux.x0 contains the log of spot underlying, default zero
  • aux.K is a vector of strike evaluation points

Contents

Example 1: Black Scholes

In the Black Scholes model, the risk neutral dynamics of the logarithmic spot process are:

$dy=(r_f - \frac{1}{2}\sigma^2)dt + \sigma dW$

resulting in the characteristic function

$\phi(u)=E(e^{uiX_T})=\exp(-r_f\tau +iux_t+ iu\tau(r_f-\frac{1}{2}\sigma^2)-\frac{1}{2}\tau u \sigma^2)$

where $\tau=T-t$.

The FFT option pricing approach of Carr/Madan rapipdly evaluates the option price as an Fourier transform of the underlying characteristic function, where $k=\log(K)$ the logarithm of the strike price:

$C = \frac{\exp(-\alpha k)}{\pi}\int_0^{\infty}\exp(-ivk) \frac{\phi(v-(\alpha+1)i)}{\alpha^2+\alpha-v^2+i(2\alpha+1)v}dv$

The characteristic function of the Black Scholes model is also included in cflib, using the argument type='BS'.

rf          = 0.05;
tau         = 1;
sigma       = 0.25;
S0          = 100;
x0          = log(S0);
cfBS        = @(u) exp(-rf*tau + i*u*x0 + i*u*(rf-1/2*sigma^2)*tau - 1/2*u.^2*sigma^2*tau);

Within the discretely spaced strike range K=[40:160], we obtain

K           = [40:160]';
aux.K       = K;
aux.x0      = x0;
CBS         = cf2call(cfBS,aux);

As a check, we test whether the option price obeys the no-arbitrage bound $C\geq \max(S_0-Ke^{-r_f\tau},0)$

bounds  = max(S0-K*exp(-rf*tau),0);
plot(K,[bounds CBS]);
title('Black Scholes option prices');
legend('Arbitrage bounds','Black Scholes prices');
xlim([80 120]);
xlabel('Strike');
ylabel('Option Price');

Example 2: Heston's stochastic volatility model

In Heston's stochastic volatility model, the risk neutral dynamics of the logarithmic spot process and the variance process are

$dy = (r_f - \frac{1}{2}v_t)dt + \sqrt{v_t}dW_1$

$dv = \kappa(\theta-v_t)dt + \sigma\sqrt{v_t}dW_2$

where $E(dW_1dW_2)=\rho dt$

The corresponding characteristic function is included in cflib using argument type='Heston'.

Let us assume in addition to example 1

$v_0=0.25^2, \kappa_v=0.85,\theta_v=0.30^2,\sigma_v=0.1,\rho=-0.7$

v0          = 0.25^2;
kappaV      = 0.85;
thetaV      = 0.30^2;
sigmaV      = 0.1;
rho         = -0.7;

Translating this into the fields of the par structure required by cflib, we obtain

par.x0      = x0;
par.v0      = v0;
par.rf      = rf;
par.q       = 0;
par.kappa   = kappaV;
par.theta   = thetaV;
par.sigma   = sigmaV;
par.rho     = rho;
aux.x0      = x0;
cfHes       = @(u) cflib(u,tau,par,'Heston');
CHes        = cf2call(cfHes,aux);
bounds      = max(S0-aux.K*exp(-par.rf*tau),0);
plot(K,[bounds CBS CHes]);
title('Comparison of Heston and Black Scholes option prices');
legend('Arbitrage bounds','Black Scholes','Heston');
xlim([80 120]);
xlabel('Strike');
ylabel('Option Price');

Example 3: Bates' model with stochastic intensity

Here, we assume the spot asset volatility to be of the Heston type and that the spot asset jumps log-exponentially with stocahstic intensity.

$dy = (r_f - \frac{1}{2}v_t - \lambda_t m)dt + \sqrt{v_t}dW_1 + JdZ$

$dv = \kappa_v(\theta_v-v_t)dt + \sigma_v\sqrt{v_t}dW_2$

$d\lambda = \kappa_{\lambda}(\theta_{\lambda}-\lambda_t)dt + \sigma_{\lambda_t}\sqrt{\lambda_t}dW_3$

where

$E(dW_1dW_2)=\rho, E(dW_1dW_3)=E(dW_2dW_3)=0$, $m=E(e^{J}-1)$

$J\sim N(\mu_J,\sigma_J)\to \theta(c)=\exp(\mu_Jc+\frac{1}{2}c^2\sigma_J^2)$ and $m=\theta(1)-1$

The corresponding characteristic function can be recovered using cfaffine. Let us assume in addition to examples 1 and 2

$\lambda_0=0.05, \kappa_{\lambda}=0.45,\theta_{\lambda}=0.10,\sigma_{\lambda}=0.1$

$\mu_J=-0.1, \sigma_J=0.05$

lambda0     = 0.10;
kappaL      = 0.45;
thetaL      = 0.15;
sigmaL      = 0.1;
muJ         = -0.25;
sigmaJ      = 0.30;
jump        = @(c) exp(c(1,:)*muJ + 1/2*c(1,:).^2*sigmaJ^2);
m           = jump(1)-1;

Transforming these parameters into the AJD coefficients required by cfaffine, we obtain

X0          = [log(S0) ; v0 ; lambda0];
K0          = [rf ; kappaV*thetaV ; kappaL*thetaL];
K1          = [0 -1/2 -m ; 0 -kappaV 0 ; 0 0 -kappaL];
H1          = zeros(3,3,3);
H1(:,:,2)   = [1 rho*sigmaV 0 ; rho*sigmaV sigmaV^2 0 ; 0 0 0];
H1(3,3,3)   = sigmaL^2;
R0          = rf;
L1          = [0 0 1]';
cfBates     = @(u) cfaffine(u,X0,tau,K0,K1,[],H1,R0,[],[],L1,jump);
[CBates]    = cf2call(cfBates,aux);
plot(K,[bounds CBS CHes CBates]);
title('Comparison of SV/SJ, Heston and Black Scholes option prices');
legend('Arbitrage bounds','Black Scholes','Heston','SV/SJ');
xlim([80 120]);
xlabel('Strike');
ylabel('Option Price');

Example 4 Option Greeks

In this example, we will compute the greeks of options, i.e. change in the option price for a small change in an underlying variable. Let us begin with the $\Delta$ of an option, which is given by

$\Delta = \frac{\partial C}{\partial S}$

A close look at the Carr/Madan option pricing formula from example 1 reveals that the derivative of the option price with respect to the underlying is

$\Delta = \frac{\partial C}{\partial S}$

$ = \frac{\exp(-\alpha k)}{S\pi}\int_0^{\infty}\exp(-ivk) \frac{i*(v-(\alpha+1)i)*\phi(v-(\alpha+1)i)}{\alpha^2+\alpha-v^2+i(2\alpha+1)v}dv$

thus we can employ the call option pricing function cf2call to evaluate the option delta by simply handing a different characteristic function

$\phi_{\Delta}(u)=i*u*\phi(u)$:

cfDelta     = @(u) exp(-x0)*i*u.*cfBS(u);

Within the discretely spaced strike range K=[40:160], we obtain

Delta       = cf2call(cfDelta,aux);

Just to make sure, compare the result with the theoretical $\Delta$

plot(K,Delta,'ro',K,blsdelta(S0,K,rf,tau,sigma,0),'b');

In the same way, we can compute the option's $\Gamma$, which is

$\Gamma=\frac{\partial^2C}{\partial S^2}$

using the corresponding characteristic function:

$\phi_{\Gamma}= -\frac{1}{S^2}(iu+u^2)\phi(u)$

cfGamma     = @(u) -exp(-2*x0)*(i*u+u.^2).*cfBS(u);
Gamma       = cf2call(cfGamma,aux);

Just to make sure, compare the result with the theoretical $\Gamma$

plot(K,Gamma,'ro',K,blsgamma(S0,K,rf,tau,sigma,0),'b');

Example 5: Greeks of Bates Model with stochastic intensity

Let us come back to example 3 above, where we assumed stochastic volatility and normally distributed return jumps with stochastic jump intensity. We are interested in the derivative of the option price with respect to

  • the spot price $S$
  • the spot variance level $v$
  • the spot intensity $\lambda$

In the spirit of example 4, we note that all we have to do is to pre-multiply the characteristic function $\phi(u)$ with that component $\beta(u)$ that corresponds to our variable of interest. If we are interested in $\Delta$, we have to divide by $S$ to obtain the final greek.

Here we require a simple function that returns the first derivatives of our characteristic function with respect to the spot levels:

function out = cfTemp(cf,u,k)
[out1, ~, out2]  = cf(u);
out = out1.*out2(k,:);
end

cfTemp knows that cf returns three outputs: the characterstic function cf(u) and the corresponding exponential constant $\alpha(u)$ the vector $\beta(u)$. See Theory for details.

Let us now evaluate the resulting greeks:

DeltaSBates     = cf2call(@(u) cfTemp(cfBates,u,1),aux)/S0;
DeltaVBates     = cf2call(@(u) cfTemp(cfBates,u,2),aux);
DeltaLBates     = cf2call(@(u) cfTemp(cfBates,u,3),aux);
subplot(3,1,1);
plot(K,DeltaSBates);
title('Bates Model \Delta');
subplot(3,1,2);
plot(K,DeltaVBates);
title('Bates Model Derivative with respect to the spot variance level');
subplot(3,1,3);
plot(K,DeltaLBates);
title('Bates Model Derivative with respect to the spot intensity level');

Example 6: Multiple strikes / maturities

In this example, we show how to compute option prices for different strike-maturity combinations in one go. Assume that the underlying security is valued at 100 USD today, and we are interested in call option prices for the following strike-maturity set:

Strikes\Maturity 1M 3M 6M 12M 24M
95 94 93 92 90
100 100 100 100 100
105 108 110 110 105

For our underlying process, we assume a Heston model with the parameters from Example 2. For the time to maturity and the strikes we introduce the following arrays:

tau         = [1 3 6 12 24]/12;
K           = [95 94 93 92 90 ;
               100 100 100 100 100 ;
               105 108 110 110 105];

Using the additional argument K in the aux structure of cf2call, we can compute all option prices in one go:

C           = cf2call(@(u) cflib(u,tau,par,'Heston'), ...
              struct('x0',par.x0,'K',K))
C =

    6.3311    9.3630   12.6840   17.5476   25.3953
    3.1068    5.7038    8.5326   12.9880   20.0154
    1.1938    2.4975    4.3447    8.5270   17.6624