Hi,
I'm trying to expose QuantLib's TreeSwaptionEngine and TimeGrid in PricingEngine to QuantLibXL. Think it is supposed to be easy, but it keeps me the following error.
Compiling... 3>create_pricingengines.cpp 3>\quantlibaddin\qlo\serialization\create\create_pricingengines.cpp(721) : error C2664: 'QuantLibAddin::TreeSwaptionEngine::TreeSwaptionEngine(const boost::shared_ptr<T> &,const boost::shared_ptr<QuantLib::OneFactorAffineModel> &,const QuantLib::TimeGrid &,bool)' : Can't conver to parameter 3 from 'QuantLib::Handle<T>' to 'const QuantLib::TimeGrid &'
3> with 3> [ 3> T=ObjectHandler::ValueObject 3> ] 3> and 3> [ 3> T=QuantLib::TimeGrid
3> ] 3> reason: Can't convert from 'QuantLib::Handle<T>' to 'const QuantLib::TimeGrid' 3> with 3> [ 3> T=QuantLib::TimeGrid
3> ] Here is the relevant files I've either created or modified. 1. create_pricingengine.cpp that generates the error message boost::shared_ptr<ObjectHandler::Object> create_qlTreeSwaptionEngine( const boost::shared_ptr<ObjectHandler::ValueObject> &valueObject) { // convert input datatypes to C++ datatypes
std::string HandleModel = ObjectHandler::convert2<std::string>(valueObject->getProperty("HandleModel")); std::string TimeGrid =
ObjectHandler::convert2<std::string>(valueObject->getProperty("TimeGrid")); bool Permanent = ObjectHandler::convert2<bool>(valueObject->getProperty("Permanent"));
// convert object IDs into library objects OH_GET_REFERENCE(HandleModelLibObjPtr, HandleModel, QuantLibAddin::OneFactorAffineModel, QuantLib::OneFactorAffineModel)
OH_GET_OBJECT(TimeGridCoerce, TimeGrid, ObjectHandler::Object) QuantLib::Handle<QuantLib::TimeGrid> TimeGridLibObj = QuantLibAddin::CoerceHandle<
QuantLibAddin::TimeGrid, QuantLib::TimeGrid>()( TimeGridCoerce); // update value object precedent IDs (if any)
valueObject->processPrecedentID(HandleModel); valueObject->processPrecedentID(TimeGrid); // construct and return the object boost::shared_ptr<ObjectHandler::Object> object( new QuantLibAddin::TreeSwaptionEngine( valueObject, HandleModelLibObjPtr,
TimeGridLibObj, Permanent)); return object; } 2. pricingengines.xml <Category name='pricingengines'> <description>functions to construct and use PricingEngine objects.</description> <displayName>Pricing Engines</displayName>
<xlFunctionWizardCategory>QuantLib - Financial</xlFunctionWizardCategory> <serializationIncludes> <include>qlo/pricingengines.hpp</include> <include>qlo/termstructures.hpp</include>
<include>qlo/shortratemodels.hpp</include> <include>qlo/payoffs.hpp</include> <include>qlo/marketmodels.hpp</include> <include>qlo/processes.hpp</include>
<include>qlo/timegrid.hpp</include> <include>ql/pricingengines/blackformula.hpp</include> <include>ql/pricingengines/blackscholescalculator.hpp</include>
<include>ql/pricingengines/swaption/treeswaptionengine.hpp</include> <include>ql/termstructures/volatility/optionlet/optionletvolatilitystructure.hpp</include> <include>ql/termstructures/volatility/swaption/swaptionvolstructure.hpp</include>
</serializationIncludes> <addinIncludes> <include>qlo/pricingengines.hpp</include> <include>qlo/termstructures.hpp</include> <include>qlo/shortratemodels.hpp</include>
<include>qlo/payoffs.hpp</include> <include>qlo/marketmodels.hpp</include> <include>qlo/processes.hpp</include> <include>qlo/timegrid.hpp</include>
<include>ql/pricingengines/blackformula.hpp</include> <include>ql/pricingengines/blackscholescalculator.hpp</include> <include>ql/pricingengines/swaption/treeswaptionengine.hpp</include>
<include>ql/termstructures/volatility/optionlet/optionletvolatilitystructure.hpp</include> <include>ql/termstructures/volatility/swaption/swaptionvolstructure.hpp</include>
</addinIncludes> <copyright> Copyright (C) 2006, 2007, 2008 Ferdinando Ametrano Copyright (C) 2007 Eric Ehlers </copyright> <Functions>
... <Constructor name='qlTreeSwaptionEngine'> <libraryFunction>TreeSwaptionEngine</libraryFunction> <SupportedPlatforms>
<!--SupportedPlatform name='Excel' calcInWizard='false'/--> <SupportedPlatform name='Excel'/> <SupportedPlatform name='Calc'/>
<SupportedPlatform name='Cpp'/> </SupportedPlatforms> <ParameterList> <Parameters> <Parameter name='HandleModel'>
<type>QuantLib::OneFactorAffineModel</type> <tensorRank>scalar</tensorRank> <description>One Factor Hull and White Swaption Pricing object ID.</description>
</Parameter> <Parameter name='TimeGrid'> <type>QuantLib::TimeGrid</type> <superType>libToHandle</superType>
<tensorRank>scalar</tensorRank> <description>TimeGrid object.</description> </Parameter> </Parameters>
</ParameterList> </Constructor> 3. pricingengine.hpp class TreeSwaptionEngine : public PricingEngine { public:
TreeSwaptionEngine( const boost::shared_ptr<ObjectHandler::ValueObject>& properties, const boost::shared_ptr<QuantLib::OneFactorAffineModel>& model,
const QuantLib::TimeGrid& timegrid, bool permanent); }; 4. pricingengine.cpp
TreeSwaptionEngine::TreeSwaptionEngine( const boost::shared_ptr<ObjectHandler::ValueObject>& properties, const boost::shared_ptr<QuantLib::OneFactorAffineModel>& model,
const QuantLib::TimeGrid& timegrid, bool permanent) : PricingEngine(properties, permanent) { libraryObject_ = boost::shared_ptr<QuantLib::PricingEngine>(new
QuantLib::TreeSwaptionEngine(model,timegrid)); } Any tip would be appreciated. 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 |
Free forum by Nabble | Edit this page |