http://quantlib.414.s1.nabble.com/CMS-Bonds-in-Python-tp458p461.html
However, I think you're making the wrong associations. You're modeling
(BlackIborCouponPricer, IborCouponPricer). Instead, CmsCouponPricer is
you'll have one of the CMS pricers defined in conundrumpricer.hpp.
class. What I'd suggest is something like:
also take a CmsCouponPricer. Write again if you get stuck, and I'll try
to find some time and send a patch.
> Hello,
>
> I am trying to create CMS Bonds in Python and thus I need to create
> the relate SWIG interface files.
> As I am quite newbie to both SWIG and Quantlib, I am currently stuck
> with the CMS pricer.
>
> I have succesfully been able to export (at least it builds without
> complains) :
>
> 1) The CMSCoupon:
>
> using QuantLib::CmsCoupon;
>
> typedef boost::shared_ptr<CashFlow> CmsCouponPtr;
>
> %rename(CmsCoupon) CmsCouponPtr;
> class CmsCouponPtr : public FloatingRateCouponPtr {
> public:
> %extend {
> CmsCouponPtr(const Date& paymentDate, Real nominal,
> const Date& startDate, const Date& endDate,
> Integer fixingDays, const
> boost::shared_ptr<SwapIndex>& index,
> Real gearing = 1.0, Spread spread = 0.0,
> const Date& refPeriodStart = Date(),
> const Date& refPeriodEnd = Date(),
> const DayCounter& dayCounter = DayCounter(),
> bool isInArrears = false) {
> const boost::shared_ptr<SwapIndex> swi =
> boost::dynamic_pointer_cast<SwapIndex>(index);
> return new CmsCouponPtr(
> new CmsCoupon(paymentDate,nominal,startDate,endDate,
> fixingDays,swi,gearing,spread,
> refPeriodStart, refPeriodEnd,
> dayCounter,isInArrears));
> }
>
> }
>
> };
>
> 2) The CMSBond:
> using QuantLib::CmsRateBond;
> typedef boost::shared_ptr<Instrument> CmsRateBondPtr;
> %rename(CmsRateBond) CmsRateBondPtr;
> class CmsRateBondPtr : public BondPtr {
> %feature("kwargs") CmsRateBondPtr;
> public:
> %extend {
> CmsRateBondPtr(Size settlementDays,
> Real faceAmount,
> const Schedule& schedule,
> const SwapIndexPtr& index,
> const DayCounter& paymentDayCounter,
> BusinessDayConvention paymentConvention,
> Natural fixingDays ,
> const std::vector<Real>& gearings ,
> const std::vector<Spread>& spreads ,
> const std::vector<Rate>& caps ,
> const std::vector<Rate>& floors,
> bool inArrears = false,
> Real redemption = 100.0,
> const Date& issueDate = Date()){
> boost::shared_ptr<SwapIndex> swap =
> boost::dynamic_pointer_cast<SwapIndex>(index);
> return new CmsRateBondPtr(
> new CmsRateBond(settlementDays,
> faceAmount,
> schedule,
> swap,
> paymentDayCounter,
> paymentConvention,
> fixingDays,
> gearings,
> spreads,
> caps,
> floors,
> inArrears,
> redemption,
> issueDate));
> }
> }
> };
>
>
> But when try to extend the current Pricers in (cashflows.i) as
> follows: (I paste all the pricers altough I am just addind the CMS
> pricer based on how the IborCouponPricer is defined).
>
> %{
> using QuantLib::FloatingRateCouponPricer;
> using QuantLib::IborCouponPricer;
> using QuantLib::BlackIborCouponPricer;
> using QuantLib::CmsCouponPricer;
> typedef boost::shared_ptr<IborCouponPricer> BlackIborCouponPricerPtr;
> typedef boost::shared_ptr<FloatingRateCouponPricer>
> CmsCouponPricerPtr;
> %}
>
>
> %ignore IborCouponPricer;
> class IborCouponPricer {
> public:
> Handle<OptionletVolatilityStructure> capletVolatility() const;
> void setCapletVolatility(const
> Handle<OptionletVolatilityStructure>& v =
>
> Handle<OptionletVolatilityStructure>());
> };
>
> %template(IborCouponPricer) boost::shared_ptr<IborCouponPricer>;
> %template(FloatingRateCouponPricer)
> boost::shared_ptr<FloatingRateCouponPricer>;
> void setCouponPricer(const Leg&, const
> boost::shared_ptr<IborCouponPricer>&);
>
>
> %rename(BlackIborCouponPricer) BlackIborCouponPricerPtr;
> class BlackIborCouponPricerPtr : public
> boost::shared_ptr<IborCouponPricer> {
> public:
> %extend {
> BlackIborCouponPricerPtr(const
> Handle<OptionletVolatilityStructure>& v =
>
> Handle<OptionletVolatilityStructure>()) {
> return new BlackIborCouponPricerPtr(new
> BlackIborCouponPricer(v));
> }
> }
> };
>
> %rename(CmsCouponPricer) CmsCouponPricerPtr;
> class CmsCouponPricerPtr : public
> boost::shared_ptr<FloatingRateCouponPricer>{
> public:
> CmsCouponPricerPtr(const Handle<SwaptionVolatilityStructure>& v
> =
>
> Handle<SwaptionVolatilityStructure>()) {
> return new CmsCouponPricerPtr(new CmsCouponPricer(v));
>
>
> }
> };
>
> I get the following error (translated to english).
>
> QuantLib/quantlib_wrap.cpp(127710) : error C2664:
> 'boost::shared_ptr<T>::shared_
> ptr(const boost::shared_ptr<T> &)' : cannot convert parameter 1 from
> 'co
> nst QuantLib::Handle<T>' to 'const boost::shared_ptr<T> &'
> with
> [
> T=QuantLib::FloatingRateCouponPricer
> ]
> and
> [
> T=QuantLib::SwaptionVolatilityStructure
> ]
> and
> [
> T=QuantLib::FloatingRateCouponPricer
> ]
> Reason: Cannot find the conversion from 'const
> QuantLib::Handle<T>'
> to 'const boost::shared_ptr<T>'
> with
> [
> T=QuantLib::SwaptionVolatilityStructure
> ]
> and
> [
> T=QuantLib::FloatingRateCouponPricer
> ]
>
> It is not clear to me if I have also to export
> FloatingRateCouponPricer...
>
> As I am quite lost with SWIG I don't know if someone could hint me a
> way to solve this or have any guidance on how to create the SWIG
> interface files for Quantlib.
>
> Thanks in advance for your help.
>
> LluĂs
> ------------------------------------------------------------------------------
> Simplify data backup and recovery for your virtual environment with vRanger.
> Installation's a snap, and flexible recovery options mean your data is safe,
> secure and there when you need it. Data protection magic?
> Nope - It's vRanger. Get your free trial download today.
>
http://p.sf.net/sfu/quest-sfdev2dev> _______________________________________________ QuantLib-users mailing list
[hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-usersgive 'em a date, but never give 'em both at once.
All of the data generated in your IT infrastructure is seriously valuable.
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.