Alan, sorry for my late response. I tried the formula from Carr and Madan (1999) for ATM option, but only replace FFT with simpson' rule. The result I calculate is quite strange, with complex number. I checked my code many times, but still cannot find out what goes wrong. I would thanks a lot if you are willing to help me.function call = HestonCallQuad(kappa,theta,sigma,rho,v0,r,T,s0,K)% Exact solution of European call option pricealpha = 1.25;k = log(K);N = 100;h = 0.0001;ts = zeros(1,N/h);call = 0;for i = 0:N/h-1 ts(i+1)=i*h; if i == 0; kroneckerDelta=1; else kroneckerDelta=0; end call = call+exp(-alpha*k)/pi*HestonIntegrand(ts(i+1),kappa,theta,sigma,rho,v0,r,T,s0,alpha,k)... *(h/3*(3+(-1)^(i+1)-kroneckerDelta));endendfunction Integ = HestonIntegrand(v,kappa,theta,sigma,rho,v0,r,T,s0,alpha,k)Integ = exp(-i*v*k).*exp(-r*T).*Hestonf(v-(alpha+1)*i,kappa,theta,sigma,rho,v0,r,T,s0)./(alpha^2+alpha-v.^2+i*(2*alpha+1).*v);endfunction f = Hestonf(phi,kappa,theta,sigma,rho,v0,r,T,s0)% characteristic function of logSt in Heston model% This code from:
http://math.nyu.edu/~atm262/fall06/comp ... odley.pdfu = -0.5;b = kappa;a = kappa*theta; x = log(s0);d = sqrt((rho*sigma*phi.*i-b).^2-sigma^2*(2*u*phi.*i-phi.^2));g = (b-rho*sigma*phi*i + d)./(b-rho*sigma*phi*i - d);C = r*phi.*i*T + a/sigma^2.*((b- rho*sigma*phi*i + d)*T - 2*log((1-g.*exp(d*T))./(1-g)));D = (b-rho*sigma*phi*i + d)./sigma^2.*((1-exp(d*T))./(1-g.*exp(d*T)));f = exp(C + D*v0 + i*phi*x);endQuoteOriginally posted by: Alanneither use fft or matlab.You probably need to both increase the cutoff and decrease the effective spacing of the points. If you want help from me, just code a simple, non-fft, simpson's rule integration and we candiscuss convergence in that. It looks like your code can be easily modified to that as I see simpson weights in there.Once you've got that working, you can go back to your fft stuff.