Re: Quantlib's equivalent of Matlab's lsqnonlin

Posted by nabbleuser2008 on
URL: http://quantlib.414.s1.nabble.com/Quantlib-s-equivalent-of-Matlab-s-lsqnonlin-tp6162p6167.html

Hi Klaus,
 Attached, pls find my test program and data. I just tried to covert some prices I'm reading from data.txt to implied volatilities and feed them into heston calibration helper. I was looking to see if there's an easier way to get the implied vols from the prices, but this is how I'm doing it at the moment. If you know a easier way, pls feel free to point those out as well.

Also, I was not sure about the value of last parameter (flatVolTS) of the BlackScholesMertonProcess should be (since my goal is to get implied vol) so I made something up.

Volatility volatility = 0.2; // I'm just setting it to some value here ... not sure if that's right.

Handle<BlackVolTermStructure> flatVolTS(boost::shared_ptr<BlackVolTermStructure>(
                new BlackConstantVol(settlementDate, volatility, dayCounter)));

boost::shared_ptr<StochasticProcess> stochasticProcess(new BlackScholesMertonProcess(s0, dividendTS, riskFreeTS, flatVolTS));


Thank you very much.

CJHestonCalibration.cppdata.txt