|
From: Tawanda G. <tg...@gm...> - 2012-10-06 15:35:44
|
I am trying to expose the FRA instrument. I have managed to write the swig file and it compiles. However, I cannot create the object. It consistently produces the error:
Wrong arguments for overloaded function 'new_ForwardRateAgreement'
Possible C/C++ prototypes are:
ForwardRateAgreementPtr::ForwardRateAgreementPtr(Date const &,Date const &,Position::Type,Rate,Real,boost::shared_ptr< IborIndex > const &,QuantLib::Handle< YieldTermStructure > const &)
ForwardRateAgreementPtr::ForwardRateAgreementPtr(Date const &,Date const &,Position::Type,Rate,Real,boost::shared_ptr< IborIndex > const &)
What am I doing wrong? Below are the contents of the swig file:
#ifndef quantlib_forwards_i
#define quantlib_forwards_i
%include instruments.i
%include termstructures.i
%include cashflows.i
%include grid.i
%include stl.i
%{
using QuantLib::Position;
using QuantLib::Forward;
using QuantLib::ForwardRateAgreement;
using QuantLib::Seasonality;
typedef boost::shared_ptr<Instrument> ForwardPtr;
typedef boost::shared_ptr<Instrument> ForwardRateAgreementPtr;
%}
struct Position {
enum Type { Long, Short};
};
%rename(Forward) ForwardPtr;
class ForwardPtr : public boost::shared_ptr<Instrument> {
public:
%extend {
Date settlementDate() {
return boost::dynamic_pointer_cast<Forward>(*self)->settlementDate();
}
BusinessDayConvention businessDayConvention() {
return boost::dynamic_pointer_cast<Forward>(*self)->businessDayConvention();
}
Rate spotValue() {
return boost::dynamic_pointer_cast<Forward>(*self)->spotValue();
}
Rate forwardValue() {
return boost::dynamic_pointer_cast<Forward>(*self)->forwardValue();
}
InterestRate impliedYield(Real underlyingSpotValue,
Real forwardValue,
Date settlementDate,
Compounding compoundingConvention,
DayCounter dayCounter) {
return boost::dynamic_pointer_cast<Forward>(*self)->impliedYield(
underlyingSpotValue,
forwardValue,
settlementDate,
compoundingConvention,
dayCounter);
}
}
protected: /* added this later, but did not help*/
Forward(const DayCounter& dayCounter,
const Calendar& calendar,
BusinessDayConvention businessDayConvention,
Natural settlementDays,
const boost::shared_ptr<Payoff>& payoff,
const Date& valueDate,
const Date& maturityDate,
const Handle<YieldTermStructure>& discountCurve =
Handle<YieldTermStructure>()) {
return new ForwardPtr(new Forward(dayCounter,
calendar,
businessDayConvention,
settlementDays,
payoff,
valueDate,
maturityDate,
discountCurve));
}
};
%rename(ForwardRateAgreement) ForwardRateAgreementPtr;
class ForwardRateAgreementPtr : public ForwardPtr {
public:
%extend {
ForwardRateAgreementPtr(
const Date& valueDate,
const Date& maturityDate,
Position::Type type,
Rate strikeForwardRate,
Real notionalAmount,
const boost::shared_ptr<IborIndex>& index,
const Handle<YieldTermStructure>& discountCurve =
Handle<YieldTermStructure>()) {
return new ForwardRateAgreementPtr(
new ForwardRateAgreement(valueDate,
maturityDate,
type,
strikeForwardRate,
notionalAmount,
index,
discountCurve));
}
Real spotIncome(const Handle<YieldTermStructure>& incomeDiscountCurve) const {
return boost::dynamic_pointer_cast<ForwardRateAgreement>(*self)-> spotIncome(
incomeDiscountCurve);
}
/*Real spotValue() {
return boost::dynamic_pointer_cast<ForwardRateAgreement>(*self)->spotValue();
}*/
}
};
#endif
|