Serving the Quantitative Finance Community

 
User avatar
vipulas
Topic Author
Posts: 0
Joined: March 20th, 2007, 6:54 am

Option Pricing with FFT using Matlab

September 28th, 2007, 9:44 am

Hi all,I'm newbie and trying to price an option using FFT as described in Carr Madan paper (1999) (Option Pricing with FFT , The Carr Madan paper ) I was following few sample codes and they have different implementations. I'm using the Variance Gamma Model. The sample 1 (Link to Source) (Characteristic function)According to the paper we need to get the characteristic function phi(v) and then have to generate the psi as in equation (6) in the paper. Then I have to plug that psi to the equation (24) to use the FFT on it to get the summation. But in the above matlab implementation they have directly used phi instead of psi. I tried modifying the code accordingly to implement the psi but it gives me a wired out put. (Please find the code below)Have I miss understood anything or have I made an error in my code. I really appreciate if someone could give me a hint on this.Cheers,Vijayfunction y = MyFFT%Option pricing using the FFT Carr Madan Method%Define the Parametersnu = .16;So = .98; % Stock Pricels = log(So); % Log Stock PriceX = 1;K = X/So% Strike Pricelk = log(K); % Log Strike Pricer = 0.059; % Risk free interest rateT = 1; % Maturity yearsigma = 0.12; % Volatilitytheta = -0.33; % theta of VG Model's characteristic function equation (26)% FFT will return N values of ln(K) values hence need to employ a regular% spacing%Define Parameteres for the GRID% All the Parameters are defined as sugested by Carr Madan% parametersa = 600; % endpoint of char fun grid (0,+a) we can either choose eta or a as in equation (18)N = 4096; % Required summations to approxymate the inegral. as in equation (24)% Normally deploy a power of 2. then Matlab uses% radix-2 algorithm wich is very fast.eta = a/N; % where a = N* eta is the effective upper limit for the integration as in equation (18)b = pi/eta % the bounds of the retuned log strike level. equation (19)lambda = (2*b)/N; % lambda = (2*b)/N lambda is the regular spacing set for the lk = log(K)%a= (2*pi)/lambda; %alpha = 1.5; % lambda has to be used to make integral of the call price square integrable%equation (3) the value of alpha is decided considering the condition in equation (7)u = (0:N-1) * eta ; % Vj as in Vj = (j -1 ) *etaku = -b + lambda * (0:N-1); % equation (19) empoying regular spacing for retunrd ku% derive the characteristic functionphi = u - (( alpha + 1) * i); % will be used when computing zhi(v) using the characteristic% function phi as in Equation (6)% Use the characteristic fucntion of VGcf = vgcf_vip(phi,theta,nu,sigma,T,r,So);v=nu;f1 = exp(-r*T) .*cf;f2 = (alpha^2 + alpha - u.^2 + i*(2*alpha + 1));zzhi = f1 ./ f2;% Create Simpson's weightsN = size(u,2);q1 = (-1).^(1:N);q2 = eye(1,N); % implements the direct deltaS = ( 3 + q1 - q2 )/3;zhi = zzhi .* S;%cft = zhi(nu,u);ft = fft( exp(i * b * u) .* zhi * eta );%cft=zhi(nu,u);Return_ku = real(ft .* exp(-alpha * ku ) /pi);%plot(exp(ku),Return_ku)plot (exp(ku),Return_ku)axis([.0 1.3 -1 1.5])grid ontitle 'Call Price VS K'xlabel 'Strike'ylabel 'Call Price'%plot (exp(ku))