Re: Implement Bermudan swaption in QuantLibXL

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

Eric,

Yeop. Thanks to your advice, I've passed the obstacle and still moving forward. 

Now I'm stuck at implementing the following segment in BermudanSwaption.cpp

        boost::shared_ptr<HullWhite> modelHW(new HullWhite(rhTermStructure));
......
        calibrateModel(modelHW, swaptions);

And the function, calibrateModel is declared as 

void calibrateModel(
          const boost::shared_ptr<CalibratedModel>& model,
          const std::vector<boost::shared_ptr<CalibrationHelper> >& helpers)

Given the fact that the above example perfectly works, I know that HullWhite can be dynamically cast to CalibratedModel in QuantLib.

Now back to QuantLibXL, I've exposed HullWhite and CalibratedModel. However, when HullWhite is throwed into CalibratedModel, it generates 

qlCalibratedModelCalibrate - Error retrieving object with id 'obj_0000e#0000' - unable to convert reference to type 'class QuantLibAddin::CalibratedModel' found instead 'class QuantLibAddin::HullWhite'

Debugging indicates that the error originates in

\ObjectHandler\oh\repository.hpp

        //! Template member function to retrieve the Object with given ID.
        /*! Retrieve the object with the given ID and downcast it to the desired type.
            Throw an exception if no Object exists with that ID.
            This template passes the work off to function retrieveObjectImpl which
            may be overridden in derived classes.
        */
        template <class T>
        void retrieveObject(boost::shared_ptr<T> &ret,
                            const std::string &id) {
            boost::shared_ptr<Object> object = retrieveObjectImpl(id);
            ret = boost::dynamic_pointer_cast<T>(object);
            OH_REQUIRE(ret, "Error retrieving object with id '"
                << id << "' - unable to convert reference to type '"
                << typeid(T).name() << "' found instead '"
                << typeid(*object).name() << "'");
        }

So my guess is that in QuantLib, QuantLib::HullWhite is dynamically castable to QuantLib::CalibratedModel while in QuantLibAddin, QuantLibAddin::Hullwhite is yet to do so to QuantLibAddin::CalibratedModel.

Please let me know where and how I can set this. 

Thanks!

- Hyung



On Tue, Jul 31, 2012 at 2:23 AM, Eric Ehlers <[hidden email]> wrote:
Hi Hyung,

On 2012-07-30 07:15, Hyung-Seok Hahm wrote:
> Another follow-up question. 
>
> I'm getting the following error. 
>
> "qlCalibratedModelCalibrate - ObjectHandler error: attempt to
> retrieve object with unknown ID..."

That run time error tells you that you are trying to retrieve an object
that does not exist.

Can you check whether the object that you are trying to retrieve has in
fact been created previously?

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

------------------------------------------------------------------------------
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