This is a code that I have used to calibrate Heston model. the following code describe the optimization algorithms used (genetic algorithm plus interior method)
function parameters = ga_Heston(S,strikes,Rate, DividendYield, Settle,Maturity,prices)
eps=1e-6
lb = [eps eps eps eps -0.99];
ub = [1 1e6 1e6 1e6 0.99];
targetfun = @(x) fitfunction(x, S,strikes,Rate, DividendYield, Settle,Maturity,prices);
parameters = ga(targetfun, 5, [], [], [], [], lb, ub, [],[]);
options = optimset('fmincon');
options = optimset(options, 'algorithm', 'interior-point');
options = optimset(options, 'Display', 'off');
parameters, funValue = fmincon(targetfun, parameters, [], [], [], [], lb, ub, [], options);
end
function value = fitfunction(param, S,strikes,Rate, DividendYield, Settle,Maturity,prices)
N=length(strikes);
model=zeros(N,1);
for k=1:N
model(k)=prices(k)-optByHestonFFT(Rate, S, ...
Settle, Maturity, 'call', strikes(k), ...
param(1), param(3), param(2), param(4), param(5), 'DividendYield', DividendYield);
end
value = norm(model)/N;
end
I have those result:
Market prices are: 0.0293 0.0126 0.0602 0.0046 0.0973 0.0022 0.1249
Model prices are: 0.0199 0.0157 0.0622 0.0106 0.0992 0.0069 0.1244
why do I have such big error on some results, what I have to do to be more precise and is there any method that can give me a good starting parameters for the optimization algorithm.
param(3)andparam(2)reversed? – Bob Jansen Feb 02 '23 at 12:48