You're welcome.Thanks, Cuchulainn. I am correctly using scipy.integrate.quad, did some test runs on standard cases.
I think the problem is the formula mentioned in the article that I am following. I am now following the book by Lewis. I think the contour variation that Alan has suggested above is a useful technique to avoid numerical instabilities when computing these integrals.
thank you,
K
I'll definitely do that.
You're welcome.
If you have time it would be nice how DE/SLSQP/(SHGO?) worked out to determine 'best practice' for this problem.
The final arbiter is the customer.Is no one worried that contour integration, poles, residues, branch cuts, etc. is not for amateurs?
I can match the reference prices to 12 digits, there was an implementation bug in my code, somewhere I used an extra ' * ' and it became an exponent operation from multiplication.A few comments.
- The H function I posted uses z instead of k; otherwise, the parameters are the same as my previous post.
- Mathematica documentation is online.
- Commented out stuff mostly related to using xmax=infinity; sometimes you can get away with this; sometimes not. The code here uses a finite xmax.
My advice to Krish at this point:
- First, get your H to agree with my H at various complex z.
- Then get your (real-valued) integrand to agree with my integrand at various positive x, defined here by [$]z = x + i/2[$]
- Finally, use my xmax cutoff, and see if you can't integrate to get my reference prices to 12 digits.
I am happy to answer questions about my code. I am unlikely to search for typos in somebody else's paper.
Hi, I used DE, shgo and SLSQP algorithms to optimize the parameters. I am calibrating this model to 96 option prices (all are call options).You're welcome.Thanks, Cuchulainn. I am correctly using scipy.integrate.quad, did some test runs on standard cases.
I think the problem is the formula mentioned in the article that I am following. I am now following the book by Lewis. I think the contour variation that Alan has suggested above is a useful technique to avoid numerical instabilities when computing these integrals.
thank you,
K
If you have time it would be nice how DE/SLSQP/(SHGO?) worked out to determine 'best practice' for this problem.
I still have a doubt though:
the sign of 'd' is different In the original book (equation 3.2) and in the code that you have shared. Why?
>> The book code potentially suffers from The Little Heston Trap
Basically, with the book code d, H(z) can cross a branch cut as z varies within [$]0 < \mbox{Im} \, z < 1[$]. That's bad. The code I posted avoids that. The posted code is also in agreement with the formulas in Gatheral's book, which also fix the issue. You should definitely use the posted code rather than the book code for H. It's also good practice to visually examine your integrand for smoothness along the contour.
and why do we consider the gamma (risk aversion) coefficient equal to 1?
>> In my book, I derive a more general version of the sqrt model which has the parameter gamma, and reduces to the "conventional" Heston model when gamma=1.
Why do you say that the Feller condition is often violated in calibration? Should I not use this as a constraint?
>> If you include shorter-dated, well out of the money options, such as those available with SPX, a calibration will often
violate the Feller condition in order to achieve a "best fit". I have seen it happen often, although I typically don't use MSE on prices as the objective function. In any event, it's harmless and there's no reason not to improve a fit by accepting a Feller condition violation.
I am reading contour integrals so that I can work with the Heston model with jumps. Trying to understand strip of regularity.
Many thanks for the helpful inputs.
>> You're welcome