CPIBond via SWIG

classic Classic list List threaded Threaded
21 messages Options
12
Reply | Threaded
Open this post in threaded view
|

CPIBond via SWIG

smazzucca
I am trying to add CPIBond to the SWIG interface file but I can tell that some of my syntax is wrong:

%rename(CPIBond) CPIBondPtr;
class CPIBondPtr : public BondPtr {
    %feature("kwargs") CPIBondPtr;
  public:
    %extend {
        CPIBondPtr(
                Real faceAmount,
                bool growthOnly,
                Real baseCPI,
                const Period& observationLag,
                const boost::shared_ptr<ZeroInflationIndex>& cpiIndex,
                CPI::InterpolationType observationInterpolation,
                const Schedule& schedule,
                const std::vector<Rate>& coupons,
                const DayCounter& accrualDayCounter,
                BusinessDayConvention paymentConvention = ModifiedFollowing,
                const Date& issueDate = Date()) {
            return new CPIBondPtr(
                new CPIBond(faceAmount, growthOnly, baseCPI,
                                                                observationLag, cpiIndex, observationInterpolation,
                                                                schedule, coupons, accrualDayCounter,
                                                                paymentConvention, issueDate));
        }
    }
};


Is there a map I can use to convert all the types ? If I had that, I think I would be more independent in doing these conversions (and I have many more in my future...).

Thank you,
Simon
Reply | Threaded
Open this post in threaded view
|

Re: CPIBond via SWIG

Luigi Ballabio
Hi Simon,
    no such luck; the conversions are only shown in the existing
wrappers. In fact, it would be great if you started compiling such a
map...

In your case: I haven't had time to check if it works (and I won't be
at work tomorrow, so I'm afraid that I'll have my next look at it on
Monday) but my guesses are:

- the CPI struct (from which you use CPI::InterpolationType) is not
exported at all. That's easy enough to do: look at the Protection
struct in credit.i.
- the shared_ptr<ZeroInflationIndex> is not exported directly, but
only through the base class Index. You have to take it as pointer to
base class and then downcast it. I'll have to sit down and write about
it sometimes. In the meantime, see how it's done when exporting
ZeroCouponInflationSwapHelper in inflation.i; declare the argument as
ZeroInflationIndexPtr and use boost::dynamic_pointer_cast to massage
it before passing it to the underlying constructor.

Later,
    Luigi


On Tue, Dec 31, 2013 at 10:33 PM, smazzucca <[hidden email]> wrote:

> I am trying to add CPIBond to the SWIG interface file but I can tell that
> some of my syntax is wrong:
>
> %rename(CPIBond) CPIBondPtr;
> class CPIBondPtr : public BondPtr {
>     %feature("kwargs") CPIBondPtr;
>   public:
>     %extend {
>         CPIBondPtr(
>                 Real faceAmount,
>                 bool growthOnly,
>                 Real baseCPI,
>                 const Period& observationLag,
>                 const boost::shared_ptr<ZeroInflationIndex>& cpiIndex,
>                 CPI::InterpolationType observationInterpolation,
>                 const Schedule& schedule,
>                 const std::vector<Rate>& coupons,
>                 const DayCounter& accrualDayCounter,
>                 BusinessDayConvention paymentConvention = ModifiedFollowing,
>                 const Date& issueDate = Date()) {
>             return new CPIBondPtr(
>                 new CPIBond(faceAmount, growthOnly, baseCPI,
>
> observationLag, cpiIndex, observationInterpolation,
>                                                                 schedule,
> coupons, accrualDayCounter,
>
> paymentConvention, issueDate));
>         }
>     }
> };
>
>
> Is there a map I can use to convert all the types ? If I had that, I think I
> would be more independent in doing these conversions (and I have many more
> in my future...).
>
> Thank you,
> Simon
>
>
>
> --
> View this message in context: http://quantlib.10058.n7.nabble.com/CPIBond-via-SWIG-tp14798.html
> Sent from the quantlib-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: CPIBond via SWIG

smazzucca
Luigi,

I'll be happy to document what I learn and especially map out the conversions. I'm sure it could save hours to future QL users.

I first made the CPI struct change by itself and that worked (had to roll back the CPIBond stuff in bonds.i and get back to a compilable state).

Then I tried for hours to convert the CPIBond but I keep getting errors. I followed your instructions on ZeroInflationIndex and this is the result:

%rename(CPIBond) CPIBondPtr;
class CPIBondPtr : public BondPtr {
    %feature("kwargs") CPIBondPtr;
  public:
    %extend {
        CPIBondPtr(
                Real faceAmount,
                bool growthOnly,
                Real baseCPI,
                const Period& observationLag,
                const ZeroInflationIndexPtr& cpiIndex,
                CPI::InterpolationType observationInterpolation,
                const Schedule& schedule,
                const std::vector<Rate>& coupons,
                const DayCounter& accrualDayCounter,
                BusinessDayConvention paymentConvention = ModifiedFollowing,
                const Date& issueDate = Date()) {
            boost::shared_ptr<ZeroInflationIndex> zeroIndex =
                boost::dynamic_pointer_cast<ZeroInflationIndex>(cpiIndex);
            return new CPIBondPtr(
                new CPIBond(faceAmount, growthOnly, baseCPI,
                                                                observationLag, zeroIndex, observationInterpolation,
                                                                schedule, coupons, accrualDayCounter,
                                                                paymentConvention, issueDate));
        }
    }
};

I get 14 compile errors. There is one specifically that does not make any sense:
error C2660: 'new_CPIBondPtr' : function does not take 11 arguments...

But all the constructors I see do take 11 arguments.

I compared everything between CPIBond and ZeroCouponInflationSwapHelper and I see no differences whatsoever as far as ZeroInflationIndex, maybe some other argument is the culprit ?

Talk to you on Monday, thanks!
S

Reply | Threaded
Open this post in threaded view
|

Re: CPIBond via SWIG

Luigi Ballabio
Hi Simon,
    please post your interface file and I'll have a look.

Luigi

P.S. Are you OK with me adding it to the main repository once it
works? I'll have a look either way, of course :)


On Thu, Jan 2, 2014 at 11:26 PM, smazzucca <[hidden email]> wrote:

> Luigi,
>
> I'll be happy to document what I learn and especially map out the
> conversions. I'm sure it could save hours to future QL users.
>
> I first made the CPI struct change by itself and that worked (had to roll
> back the CPIBond stuff in bonds.i and get back to a compilable state).
>
> Then I tried for hours to convert the CPIBond but I keep getting errors. I
> followed your instructions on ZeroInflationIndex and this is the result:
>
> %rename(CPIBond) CPIBondPtr;
> class CPIBondPtr : public BondPtr {
>     %feature("kwargs") CPIBondPtr;
>   public:
>     %extend {
>         CPIBondPtr(
>                 Real faceAmount,
>                 bool growthOnly,
>                 Real baseCPI,
>                 const Period& observationLag,
>                 const ZeroInflationIndexPtr& cpiIndex,
>                 CPI::InterpolationType observationInterpolation,
>                 const Schedule& schedule,
>                 const std::vector<Rate>& coupons,
>                 const DayCounter& accrualDayCounter,
>                 BusinessDayConvention paymentConvention = ModifiedFollowing,
>                 const Date& issueDate = Date()) {
>             boost::shared_ptr<ZeroInflationIndex> zeroIndex =
>                 boost::dynamic_pointer_cast<ZeroInflationIndex>(cpiIndex);
>             return new CPIBondPtr(
>                 new CPIBond(faceAmount, growthOnly, baseCPI,
>                                                                 observationLag, zeroIndex, observationInterpolation,
>                                                                 schedule, coupons, accrualDayCounter,
>                                                                 paymentConvention, issueDate));
>         }
>     }
> };
>
> I get 14 compile errors. There is one specifically that does not make any
> sense:
> error C2660: 'new_CPIBondPtr' : function does not take 11 arguments...
>
> But all the constructors I see do take 11 arguments.
>
> I compared everything between CPIBond and ZeroCouponInflationSwapHelper and
> I see no differences whatsoever as far as ZeroInflationIndex, maybe some
> other argument is the culprit ?
>
> Talk to you on Monday, thanks!
> S
>
>
>
>
>
> --
> View this message in context: http://quantlib.10058.n7.nabble.com/CPIBond-via-SWIG-tp14798p14809.html
> Sent from the quantlib-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: CPIBond via SWIG

smazzucca
Yes, of course, feel free to share. Thanks so much.

bonds.i attached.

bonds.i
Reply | Threaded
Open this post in threaded view
|

Re: CPIBond via SWIG

Luigi Ballabio
Hi Simon,
    the trick is to look at the first compilation error, not the last.
It said: "error: ‘ZeroInflationIndex’ was not declared in this scope".
You just have to include inflation.i at the beginning of your interface file.

I'll include your modification in the main repository shortly. Do you
also have the interface for the tree callable-bond engine? And should
I assign the copyright of the changes to you, or to your employer (if
any)?

Later,
    Luigi


On Tue, Jan 7, 2014 at 4:04 PM, smazzucca <[hidden email]> wrote:

> Yes, of course, feel free to share. Thanks so much.
>
> bonds.i attached.
>
> bonds.i <http://quantlib.10058.n7.nabble.com/file/n14820/bonds.i>
>
>
>
> --
> View this message in context: http://quantlib.10058.n7.nabble.com/CPIBond-via-SWIG-tp14798p14820.html
> Sent from the quantlib-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: CPIBond via SWIG

smazzucca
Fantastic, thanks! I thought I checked that, but obviously I didn't...

This is the interface file I modified for the TreeCallableFixedRateBondEngine:
shortratemodels.i

Feel free to use my name for the copyright, thanks.

Best,
Simon
Reply | Threaded
Open this post in threaded view
|

Re: CPIBond via SWIG

Luigi Ballabio
I've added them, thanks.

Luigi

On Wed, Jan 8, 2014 at 5:19 PM, smazzucca <[hidden email]> wrote:

> Fantastic, thanks! I thought I checked that, but obviously I didn't...
>
> This is the interface file I modified for the
> TreeCallableFixedRateBondEngine:
> shortratemodels.i
> <http://quantlib.10058.n7.nabble.com/file/n14825/shortratemodels.i>
>
> Feel free to use my name for the copyright, thanks.
>
> Best,
> Simon
>
>
>
> --
> View this message in context: http://quantlib.10058.n7.nabble.com/CPIBond-via-SWIG-tp14798p14825.html
> Sent from the quantlib-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: CPIBond via SWIG

smazzucca
Many thanks to you!
Simon
Reply | Threaded
Open this post in threaded view
|

Re: CPIBond via SWIG

smazzucca
Luigi,

SWIG translates the CPIBond constructor to:

public CPIBond(
        uint settlementDays,
        double faceAmount,
        bool growthOnly,
        double baseCPI,
        Period observationLag,
        ZeroInflationIndex cpiIndex,
        CPI.InterpolationType observationInterpolation,
        Schedule schedule,
        DoubleVector coupons,
        DayCounter accrualDayCounter,
        BusinessDayConvention paymentConvention,
        Date issueDate
        ) : this(NQuantLibcPINVOKE.new_CPIBond(
                        settlementDays,
                        faceAmount,
                        growthOnly,
                        baseCPI,
                        Period.getCPtr(observationLag),
                        ZeroInflationIndex.getCPtr(cpiIndex),
                        (int)observationInterpolation,
                        Schedule.getCPtr(schedule),
                        DoubleVector.getCPtr(coupons),
                        DayCounter.getCPtr(accrualDayCounter),
                        (int)paymentConvention,
                        Date.getCPtr(issueDate)),
                        true)
{
        if (NQuantLibcPINVOKE.SWIGPendingException.Pending)
                throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
}

What is the correct way to build the ZeroInflationIndex cpiIndex parameter ?

Thank you!
Simon
Reply | Threaded
Open this post in threaded view
|

Re: CPIBond via SWIG

Luigi Ballabio
I'm not sure that I understand the question. You should have a
ZeroInflationIndex class with a corresponding constructor (or,
possibly, classes that inherit from ZeroInflationIndex such as EUHICP
or UKRPI). What is the problem you're having?

Luigi

On Tue, Jan 14, 2014 at 11:24 PM, smazzucca <[hidden email]> wrote:

> Luigi,
>
> SWIG translates the CPIBond constructor to:
>
> public CPIBond(
>         uint settlementDays,
>         double faceAmount,
>         bool growthOnly,
>         double baseCPI,
>         Period observationLag,
>         ZeroInflationIndex cpiIndex,
>         CPI.InterpolationType observationInterpolation,
>         Schedule schedule,
>         DoubleVector coupons,
>         DayCounter accrualDayCounter,
>         BusinessDayConvention paymentConvention,
>         Date issueDate
>         ) : this(NQuantLibcPINVOKE.new_CPIBond(
>                         settlementDays,
>                         faceAmount,
>                         growthOnly,
>                         baseCPI,
>                         Period.getCPtr(observationLag),
>                         ZeroInflationIndex.getCPtr(cpiIndex),
>                         (int)observationInterpolation,
>                         Schedule.getCPtr(schedule),
>                         DoubleVector.getCPtr(coupons),
>                         DayCounter.getCPtr(accrualDayCounter),
>                         (int)paymentConvention,
>                         Date.getCPtr(issueDate)),
>                         true)
> {
>         if (NQuantLibcPINVOKE.SWIGPendingException.Pending)
>                 throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
> }
>
> What is the correct way to build the ZeroInflationIndex cpiIndex parameter ?
>
> Thank you!
> Simon
>
>
>
> --
> View this message in context: http://quantlib.10058.n7.nabble.com/CPIBond-via-SWIG-tp14798p14844.html
> Sent from the quantlib-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> CenturyLink Cloud: The Leader in Enterprise Cloud Services.
> Learn Why More Businesses Are Choosing CenturyLink Cloud For
> Critical Workloads, Development Environments & Everything In Between.
> Get a Quote or Start a Free Trial Today.
> http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: CPIBond via SWIG

smazzucca
Sorry, let me clarify.

Just to start with something, I have this:

ZeroInflationTermStructureHandle zeroInflationTermStructure = new ZeroInflationTermStructureHandle();
ZeroInflationIndex zeroInflationIndex = new UKRPI(false,  zeroInflationTermStructure);

And when I use zeroInflationIndex in the CPIBond constuctor I get:
"|baseCPI_| < 1e-16, future divide-by-zero problem"
   
I assume I have to use the other ZeroInflationTermStructureHandle constructor. But I'm not sure what to pass. Do you know of any samples I can use, the only one I found was too c++ centric to use.

Thanks so much,
Simon
Reply | Threaded
Open this post in threaded view
|

Re: CPIBond via SWIG

smazzucca
Even if you don't have a full answer, any help to move in the right direction would be greatly appreciated!

Thank you,
Simon
Reply | Threaded
Open this post in threaded view
|

Re: CPIBond via SWIG

Luigi Ballabio
In reply to this post by smazzucca
I'd try looking at the code in the QuantLib test suite. It's C++, but
it shouldn't be too hard to translate it. Just ignore shared_ptr.

Luigi

On Thu, Jan 16, 2014 at 5:01 PM, smazzucca <[hidden email]> wrote:

> Sorry, let me clarify.
>
> Just to start with something, I have this:
>
> ZeroInflationTermStructureHandle zeroInflationTermStructure = new
> ZeroInflationTermStructureHandle();
> ZeroInflationIndex zeroInflationIndex = new UKRPI(false,
> zeroInflationTermStructure);
>
> And when I use zeroInflationIndex in the CPIBond constuctor I get:
> "|baseCPI_| < 1e-16, future divide-by-zero problem"
>
> I assume I have to use the other ZeroInflationTermStructureHandle
> constructor. But I'm not sure what to pass. Do you know of any samples I can
> use, the only one I found was too c++ centric to use.
>
> Thanks so much,
> Simon
>
>
>
> --
> View this message in context: http://quantlib.10058.n7.nabble.com/CPIBond-via-SWIG-tp14798p14861.html
> Sent from the quantlib-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> CenturyLink Cloud: The Leader in Enterprise Cloud Services.
> Learn Why More Businesses Are Choosing CenturyLink Cloud For
> Critical Workloads, Development Environments & Everything In Between.
> Get a Quote or Start a Free Trial Today.
> http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: CPIBond via SWIG

smazzucca
I did and I made some progress, but I don't see anything anywhere about how to properly setup the ZeroInflationIndex param to pass the constructor.

With this code:

            ZeroInflationTermStructure zeroInflation = new ZeroInflationTermStructure();
            ZeroInflationTermStructureHandle zeroInflationTermStructure = new ZeroInflationTermStructureHandle(zeroInflation);
            ZeroInflationIndex zeroInflationIndex = new USCPI(false,  zeroInflationTermStructure);  

            CPIBond result = new CPIBond(
                (uint)SettlementDays,
                FaceAmount,
                growthOnly,
                BaseIndex,
                period,
                zeroInflationIndex,
                observationInterpolation,
                _Schedule,
                yields,
                DayCounter,
                _BusinessDayConvention,
                IssueDate
            );


I get this error (I assume it's because the curve is empty):
empty Handle cannot be dereferenced

Thanks,
Simon
Reply | Threaded
Open this post in threaded view
|

Re: CPIBond via SWIG

smazzucca
To add to my previous post, could it be this is a SWIG issue ?

In QuantLib ZeroInflationTermStructure has 3 constructors, but in my code all I can do is:

ZeroInflationTermStructure zeroInflation = new ZeroInflationTermStructure();

That seems wrong.
Reply | Threaded
Open this post in threaded view
|

Re: CPIBond via SWIG

Luigi Ballabio
You shouldn't even be able to do that; ZeroInflationTermStructure is
an abstract class.  You have to instantiate one of his children
classes, and I think the only one that's exported right now is
PiecewiseZeroInflation. Unfortunately, it's a bit of a hassle; but
it's done in QuantLib/test-suite/inflationcpibond.cpp. You should be
able to look at that and translate it to C#. As I said, just
discarding the shared_ptr should get you there. Also,
PiecewiseZeroInflationCurve<Linear> will be PiecewiseZeroInflation.
You already figured out how the handles are called. And yes, the error
was that the handle is empty.

Later,
    Luigi


On Fri, Jan 24, 2014 at 10:08 PM, smazzucca <[hidden email]> wrote:

> To add to my previous post, could it be this is a SWIG issue ?
>
> In QuantLib ZeroInflationTermStructure has 3 constructors, but in my code
> all I can do is:
>
> /ZeroInflationTermStructure zeroInflation = new
> ZeroInflationTermStructure();/
>
> That seems wrong.
>
>
>
> --
> View this message in context: http://quantlib.10058.n7.nabble.com/CPIBond-via-SWIG-tp14798p14895.html
> Sent from the quantlib-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> CenturyLink Cloud: The Leader in Enterprise Cloud Services.
> Learn Why More Businesses Are Choosing CenturyLink Cloud For
> Critical Workloads, Development Environments & Everything In Between.
> Get a Quote or Start a Free Trial Today.
> http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: CPIBond via SWIG

smazzucca
Luigi,

I tried that, it looks like this:

            ZeroHelperVector zeroHelperVector = new ZeroHelperVector();
            BackwardFlat backwardFlat = new BackwardFlat();

            ZeroInflationTermStructure piecewiseZeroInflation = new PiecewiseZeroInflation(
                ScenarioDate,
                _Calendar,
                DayCounter,
                period,
                Frequency,
                indexIsInterpolated,
                baseZeroRate,
                _DiscountCurve,
                zeroHelperVector,
                accuracy,
                backwardFlat);

The second I instantiate the above I get: "no bootstrap helpers given", however we are trying to do this without using bootstrap values. I feel like I must be missing something to indicate that.

Thanks,
Simon
Reply | Threaded
Open this post in threaded view
|

Re: CPIBond via SWIG

Luigi Ballabio
You'll need at least one helper (I think one is enough). Otherwise the
curve won't have any data.

Luigi

On Mon, Jan 27, 2014 at 6:07 PM, smazzucca <[hidden email]> wrote:

> Luigi,
>
> I tried that, it looks like this:
>
>             ZeroHelperVector zeroHelperVector = new ZeroHelperVector();
>             BackwardFlat backwardFlat = new BackwardFlat();
>
>             ZeroInflationTermStructure piecewiseZeroInflation = new
> PiecewiseZeroInflation(
>                 ScenarioDate,
>                 _Calendar,
>                 DayCounter,
>                 period,
>                 Frequency,
>                 indexIsInterpolated,
>                 baseZeroRate,
>                 _DiscountCurve,
>                 zeroHelperVector,
>                 accuracy,
>                 backwardFlat);
>
> The second I instantiate the above I get: "/no bootstrap helpers given/",
> however we are trying to do this /without/ using bootstrap values. I feel
> like I must be missing something to indicate that.
>
> Thanks,
> Simon
>
>
>
> --
> View this message in context: http://quantlib.10058.n7.nabble.com/CPIBond-via-SWIG-tp14798p14901.html
> Sent from the quantlib-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> CenturyLink Cloud: The Leader in Enterprise Cloud Services.
> Learn Why More Businesses Are Choosing CenturyLink Cloud For
> Critical Workloads, Development Environments & Everything In Between.
> Get a Quote or Start a Free Trial Today.
> http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable
security intelligence. It gives you real-time visual feedback on key
security issues and trends.  Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: CPIBond via SWIG

smazzucca
OK, I assume you mean I need to create a ZeroCouponInflationSwapHelper and add it to the ZeroHelperVector collection.

Now the last parameter is a ZeroInflationIndex.

How do I instantiate it ? What type ?
Am I supposed to pass it by ref ?

I don't see a way to that.

Thanks,
Simon
12