%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% %%% Option pricer for European option under Merton jump-diffusion model using %%% the FFT method of Carr, Madan 1999 %%% %%% Copyright (C) 2008 Vladimir Surkov %%% %%% %%% This program is free software: you can redistribute it and/or modify %%% it under the terms of the GNU General Public License as published by %%% the Free Software Foundation, either version 3 of the License, or %%% (at your option) any later version. %%% %%% This program is distributed in the hope that it will be useful, %%% but WITHOUT ANY WARRANTY; without even the implied warranty of %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the %%% GNU General Public License for more details. %%% %%% You should have received a copy of the GNU General Public License %%% along with this program. If not, see . %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [values_call, values_put, time] = CarrMadanFFT_European_MertonJumpDiffusion(S, K, T, sigma, lambda, mu, nu, r, q) values_call = zeros(length(S), length(K)); values_put = zeros(length(S), length(K)); time = cputime; N = 4096; gamma = 0.25; alpha = 1.5; beta = 2*pi/(gamma*N); b = N*beta/2; m =1:N; k = -b+beta*(m-1); %Set constants const = @(m)(exp(-alpha*k(m))/pi); kron = @(n)(n==0); v = gamma*(m-1); process_drift = lambda*(exp(mu+0.5*nu^2)-1); for iter_s = 1:length(S) %Set Fourier transform of pdf and payoff pdf_ft = @(u)(exp(i*u*log(S(iter_s))+ i*u*(r-q-0.5*sigma^2-process_drift)*T-0.5*u.^2*sigma^2*T + lambda*(exp(i*mu*u-0.5*(nu*u).^2)-1)*T)); payoff_call_ft = @(u)(exp(-r*T).*pdf_ft(u-(alpha+1)*i)./(alpha^2+alpha-u.^2+i*(2*alpha+1)*u)); integrand_call = @(j)(exp(i*b*v(j)).*payoff_call_ft(v(j))*(gamma/3).*(3+(-1).^(j)-kron(j-1))); %Matlab uses -i in fft, thus use forward transform, not backward values = real(const(m).*fft(integrand_call(1:N))); values_call(iter_s,:) = interp1(exp(k), values, K); values_put(iter_s,:) = values_call(iter_s,:) - S(iter_s)*exp(-q*T) + K*exp(-r*T); end time = cputime - time; time = time*2; % because we use put-call parity for put options