0
$\begingroup$

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.

$\endgroup$
3
  • $\begingroup$ Possibly stupid question: why are param(3) and param(2) reversed? $\endgroup$
    – Bob Jansen
    Commented Feb 2, 2023 at 12:48
  • 1
    $\begingroup$ Because in matlab they are using the following order $\nu_0, \theta, \kappa, \sigma, \rho$, for me to remember them I am using their order as in Heston model so I use this order $\nu_0, \kappa, \theta, \sigma, \rho$. $\endgroup$
    – User2089
    Commented Feb 2, 2023 at 13:14
  • $\begingroup$ Hi. Only having 5 parameters, there is no reason that the Heston model would perfectly fit the market in general. To check if there is not a bug in your calibration process would: (1) fix a set of Heston parameters (2) generate option prices based on them for some strikes (3) use your fitting procedure with an initial guess far from the actual parameter set (4) check whether you fallback on your feet. Some further comments: (a) I would fit implied vols rather than prices; (b) the FFT method could allow you to compute all strikes in one go rather than having a loop, careful with precision OTMF $\endgroup$
    – Quantuple
    Commented Feb 6, 2023 at 12:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.