Re: Implement Bermudan swaption in QuantLibXL

Posted by Hyung-Seok Hahm on
URL: http://quantlib.414.s1.nabble.com/Implement-Bermudan-swaption-in-QuantLibXL-tp291p294.html

After sending the last one, I've found out that HullWhite and Vasicek derived from ShortRateModel have been exposed. 

Then the remaining part I guess is how to expose

(1) CalibrationHelper class 
(2) ShortRateModel->calibrate

I will follow the tutorial for template classes for (1). 

And I do not have a clue how to deal with (2), but think the closest function among already exposed is qlCTSMMCapletCalibrationCalibrate (), so I will try to reengineer it.

In the meantime, if you have any tips, please let me know.

Thanks!

- Hyung

On Wed, Jul 4, 2012 at 10:16 AM, Hyung-Seok Hahm <[hidden email]> wrote:
Hi Eric,

Yes, I have and I have successfully exposed simple classes such as Stock before. 

However, I believe this case is more complicated. As I understand, in order to run the following segment of the code, three building blocks have been exposed. 

>
    model->calibrate(helpers, om,
                     EndCriteria(400, 100, 1.0e-8, 1.0e-8, 1.0e-8));

>

Here is the breakdown.

(1) model is a ShortRateModel object and has not been exposed in QuantLibXL
(2) helpers is a CalibrationHelper object and has not been exposed
(3) om is a LevenbergMarquart object and HAS BEEN exposed
(4) EndCriteria HAS BEEN exposed

So now the question is how to expose ShortRateModel and CalibrationHelper.

There are 2 kinds of tutorials written by you. 

One for template classes 

and the other for simple classes

I believe ShortRateModel qualifies for simple classes and CalibrationHelper for template classes. Am I on the right track?

Or if you have any better ways, please enlighten me. 

Thanks!

- Hyung



On Wed, Jul 4, 2012 at 4:40 AM, Eric Ehlers <[hidden email]> wrote:
Hi Hyung,

Have you seen the document below?

http://quantlib.org/quantlibaddin/extend_tutorial.html

Regards,
Eric

===================================================
Eric Ehlers
nazcatech sprl | Brussels | http://www.nazcatech.be
* Distributed computing for pricing analytics
* Use Microsoft Excel as a client to the Grid

Quoting Hyung-Seok Hahm <[hidden email]>:

> Hi all,
>
> I'm trying to implement Bermudan swaption in QuantLibXL.
>
> There is a swaption example, named InterestRateDerivatives.xls as one of
> the StandaloneExamples in QuantLIbXL. Plus, there is another example for
> Bermudan swaption named BermudanSwaption.cpp as one of the Quantlib
> examples.
>
> Basically what I'm trying to do is fill in the gap between these two
> examples. The problem lies in the fact that ShortRateModel and
> CalibrationHelper have not been implemented yet. To be more specific, I
> need to implement the following segment in BermudanSwaption.cpp.
>
> void calibrateModel(
>           const boost::shared_ptr<ShortRateModel>& model,
>           const std::vector<boost::shared_ptr<CalibrationHelper> >&
> helpers) {
>
>     LevenbergMarquardt om;
> *    model->calibrate(helpers, om,*
> *                     EndCriteria(400, 100, 1.0e-8, 1.0e-8, 1.0e-8));*
>
>     // Output the implied Black volatilities
>     for (Size i=0; i<numRows; i++) {
>         Size j = numCols - i -1; // 1x5, 2x4, 3x3, 4x2, 5x1
>         Size k = i*numCols + j;
>         Real npv = helpers[i]->modelValue();
>         Volatility implied = helpers[i]->impliedVolatility(npv, 1e-4,
>                                                            100000, 0.05,
> 0.50);
>         Volatility diff = implied - swaptionVols[k];
>
>         std::cout << i+1 << "x" << swapLenghts[j]
>                   << std::setprecision(5) << std::noshowpos
>                   << ": model " << std::setw(7) << io::volatility(implied)
>                   << ", market " << std::setw(7)
>                   << io::volatility(swaptionVols[k])
>                   << " (" << std::setw(7) << std::showpos
>                   << io::volatility(diff) << std::noshowpos << ")\n";
>     }
> }
>
> I do not have a clue how to expose model->calibrate part in QuantLibXL.
>
> I've been struggling with this for days, so any suggestion would be
> appreciatedl.
>
> Thanks.
>
> - Hyung
>


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users






------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users