quick code check

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

quick code check

David Pearce-4
Hi,
 
I'm fairly new to C++ and QuantLib, but have been given a dissertation project on them.
 
I'm trying to expose the inflation helpers class and have written the hpp and cpp code, but was hoping that someone may be able to proof what I've done and suggest any amendments.
 
The hpp file contents:
 
//qlo_inflation_helpers.hpp
#ifndef qla_inflation_helpers_hpp
#define qla_inflation_helpers_hpp
#include <oh/libraryobject.hpp>
#include <ql/termstructures/inflation/piecewisezeroinflationcurve.hpp>
#include <ql/time/businessdayconvention.hpp>
#include <ql/types.hpp>
#include <ql/time/frequency.hpp>
//#include <ql/handle.hpp>
namespace QuantLib {
class ZeroInflationTermStructure;

template<class TS>
class BootstrapHelper;
typedef BootstrapHelper<ZeroInflationTermStructure> ziRateHelper;
class Quote;
class Period;
class Date;
class Calendar;
class DayCounter;
class ZeroInflationIndex;
template <class T>
class Handle;
}
namespace QuantLibAddin {
class ziRateHelper : public ObjectHandler::LibraryObject<QuantLib::ziRateHelper> {
protected:
OH_LIB_CTOR(ziRateHelper, QuantLib::ziRateHelper);
};
class ZeroCouponInflationSwapHelper : public ziRateHelper{
public:
ZeroCouponInflationSwapHelper(
const boost::shared_ptr<ObjectHandler::ValueObject>& properties,
const QuantLib::Handle<QuantLib::Quote>& quote,
const QuantLib::Period& p,
const QuantLib::Date& maturity,
const QuantLib::Calendar& calendar,
QuantLib::BusinessDayConvention paymentConvention,
const QuantLib::DayCounter& dayCounter,
const boost::shared_ptr<QuantLib::ZeroInflationIndex>& zii,
bool permanent);
};
}
#endif
 
 
And the cpp file contents:
 
//qlo_inflation_helpers.cpp
#ifdef HAVE_CONFIG_H
#include <qlo/config.hpp>
#endif
#include <qlo/inflationhelpers.hpp>
#include <ql/termstructures/inflation/inflationhelpers.hpp>
//#include <qlo/qladdindefines.hpp>
//#include <ql/quote.hpp>
#include <ql/time/imm.hpp>
#include <ql/types.hpp>
#include <oh/repository.hpp>
namespace QuantLibAddin {
ZeroCouponInflationSwapHelper::ZeroCouponInflationSwapHelper(
const boost::shared_ptr<ObjectHandler::ValueObject>& properties,
const QuantLib::Handle<QuantLib::Quote>& quote,
const QuantLib::Period& p,
const QuantLib::Date& maturity,
const QuantLib::Calendar& calendar,
QuantLib::BusinessDayConvention paymentConvention,
const QuantLib::DayCounter& dayCounter,
const boost::shared_ptr<QuantLib::ZeroInflationIndex>& zii,
bool permanent)
: ziRateHelper(properties, permanent) {
libraryObject_ = boost::shared_ptr<QuantLib::ziRateHelper>
(
new QuantLib::ZeroCouponInflationSwapHelper(quote,
p,
maturity,
calendar,
paymentConvention,
dayCounter,
zii
));
}
}
 
Also, inflationhelpers.xml:
 
<Category name='inflationhelpers'>
<
description>functions to construct and use ziRateHelper objects.</description>
<
displayName>ziRateHelper</displayName>
<
xlFunctionWizardCategory>QuantLib - Financial</xlFunctionWizardCategory>
<
includes>
<
include>qlo/inflationhelpers.hpp</include>
</
includes>
<Functions>
<Constructor name = 'qlZeroCouponInflationSwapHelper'>
<
libraryFunction>ZeroCouponInflationSwapHelper</libraryFunction>
<
SupportedPlatforms>
<!--
SupportedPlatform name='Excel' calcInWizard='false'/-->
<
SupportedPlatform name='Excel'/>
<
SupportedPlatform name='Calc'/>
<
SupportedPlatform name='Cpp'/>
</
SupportedPlatforms>
<
ParameterList>
<
Parameters>
<
Parameter name='Quote' exampleValue='0.036565'>
<
type>QuantLib::Quote</type>
<
superType>libToHandle</superType>
<
tensorRank>scalar</tensorRank>
<
description>deposit quote.</description>
</
Parameter>
<
Parameter name='Period' exampleValue='6M'>
<
type>QuantLib::Period</type>
<
tensorRank>scalar</tensorRank>
<
description>deposit length (e.g. 3M for three months).</description>
</
Parameter>
<
Parameter name='Maturity' exampleValue='H2'>
<
type>QuantLib::Date</type>
<
tensorRank>scalar</tensorRank>
<
description>IMM date (or code).</description>
</
Parameter>
<
Parameter name='Calendar' exampleValue='TARGET'>
<
type>QuantLib::Calendar</type>
<
tensorRank>scalar</tensorRank>
<
description>holiday calendar (e.g. TARGET).</description>
</
Parameter>
<
Parameter name='Convention' exampleValue='Modified Following'>
<
type>QuantLib::BusinessDayConvention</type>
<
tensorRank>scalar</tensorRank>
<
description>business day convention (e.g. Modified Following).</description>
</
Parameter>
<
Parameter name='DayCounter' exampleValue='Actual/360'>
<
type>QuantLib::DayCounter</type>
<
tensorRank>scalar</tensorRank>
<
description>DayCounter ID.</description>
</
Parameter>
</
Parameters>
</
ParameterList>
</
Constructor>
</Functions>
</Category>
 
I've also followed the steps in the tutorial, added the appropriate files to corresponding projects, and have defined ziRateHelper in types.xml.
 
However when building the QuantLibXL full I encounter the following errors:
 

3>qlo\serialization\create\create_inflationhelpers.cpp(106): error C2661: 'QuantLibAddin::ZeroCouponInflationSwapHelper::ZeroCouponInflationSwapHelper' : no overloaded function takes 8 arguments
4>------ Build started: Project: QuantLibXLStatic, Configuration: Release (static runtime) Win32 ------
4> inflationhelpers.cpp
4>functions\inflationhelpers.cpp(113): error C2661: 'QuantLibAddin::ZeroCouponInflationSwapHelper::ZeroCouponInflationSwapHelper' : no overloaded function takes 8 arguments
 
 
Apologies for the abundance of code, but I've got no one else I can go to for assistance. If anyone can offer any sort of help it would be greatly appreaciated as I've been trying to rectify the problem without success for a while now.
 
Regards,
 
David

------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts.
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users