MATLAB Examples

cflib

Returns the characteristic function evaluation of commonly encountered models in finance. Part of the CFH Toolbox.

Syntax

W = CFLIB(U,TAU,PAR,TYPE)

For model choice TYPE='BS','BSJump','Heston','HestonJump','Kou', this function returns the characteristic function at real argument U for a maturity TAU and a parameter structure PAR.

Input Arguments U can either be a (K)x(1) or (1)x(K) array of characteristic function arguments. TAU denotes the time to maturity under consideration. PAR is a structure that corresponds to the required parameters of the model choice in TYPE.

Contents

Example 1: Black Scholes Model

In the Black Scholes model, the 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 characteristic function of the Black Scholes model is also included in cflib, using the argument type='BS'.

S0          = 1;
par.rf      = 0.05;
par.q       = 0;
tau         = 1;
par.sigma   = 0.25;
par.x0      = log(S0);
cf          = @(u) cflib(u,tau,par,'BS');
[fB xB]     = cf2pdf(cf);
plot(xB,fB);

Example 2: Heston's stochastic volatility model with Merton type jumps

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

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

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

where $E(dW_1dW_2)=\rho dt$

Here, $\lambda$ is the constant intensity of the jump process $dZ$ and % $m$ is the risk neutral drift adjustment. Let

$\theta(c)=E(\exp(cJ))=\exp(\mu_Jc + \frac{1}{2}c^2\sigma_J^2)$

then

$m=E(\exp(J)-1)=\theta(1)-1$

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

Let us assume in addition to Example 1 above

$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.v0      = v0;
par.kappa   = kappaV;
par.theta   = thetaV;
par.sigma   = sigmaV;
par.rho     = rho;
cf          = @(u) cflib(u,tau,par,'Heston');
[fH xH]     = cf2pdf(cf);
plot(xH,fH,'r',xB,fB,'k');
title('Comparison of implied densities of HestonJump and Black Scholes model');
legend('Heston Model with Jumps','Black Scholes');

Example 3: Kou's model

In Kou's model, we assume that the asset follows a geometric Brownian motion with double exponentially distributed jumps of constant intensity. With probability $p^+$, a given jump will be exponentially distributed over positive the reals with expected jump size $\mu^+$, whereas with probability $1-p^+$, the jump will be exponentially distributed over the negative reals with mean jump size $-\mu^-$.

Let us assume in addition to Example 1 above

$p^+=0.4, \mu^+=0.03,\mu^-=0.10,\lambda=0.1$

par.lambda  = 0.15;
par.pUp     = 0.4;
par.mUp     = 0.03;
par.mDown   = 0.15;
par.sigma   = 0.25;
cf          = @(u) cflib(u,tau,par,'Kou');
[fK xK]     = cf2pdf(cf);
plot(xK,fK,'r',xB,fB,'k');
title('Comparison of implied densities of Kou and Black Scholes model');
legend('Kou','Black Scholes');