Login  Register

Re: RelinkableHandle<YieldTermStructure> reset to Null

Posted by Breig, Dr. Christoph (IDS GmbH) on Oct 23, 2013; 9:13pm
URL: http://quantlib.414.s1.nabble.com/RelinkableHandle-YieldTermStructure-reset-to-Null-tp14597p14611.html

Hi Luigi, hi all,
yes, here is it. Do you have an idea how to reset "discTermStructure" after the initialisation of "spreadedDiscTermStructure".
-------------------
#include <ql/quantlib.hpp>

using namespace QuantLib;

int main(int, char* []) {

    try {
               
                QuantLib::RelinkableHandle<QuantLib::YieldTermStructure> discTermStructure;
                boost::shared_ptr<YieldTermStructure> nullYTSPtr;
                Date evaluationDate = Date(23,Month(10),2013);
                boost::shared_ptr<YieldTermStructure> yts(new FlatForward(evaluationDate, 0.02, ActualActual()));
                discTermStructure.linkTo(yts);
                boost::shared_ptr<Quote> spread(new SimpleQuote(0.02));

                // no problem
                discTermStructure.linkTo(nullYTSPtr);
                discTermStructure.linkTo(yts);

                // problem
                boost::shared_ptr<YieldTermStructure> spreadedDiscTermStructure(new ZeroSpreadedTermStructure(discTermStructure,Handle<Quote>(spread)));
                discTermStructure.linkTo(nullYTSPtr);
               
                system("PAUSE");
        return 0;

    } catch (std::exception& e) {
        std::cerr << e.what() << std::endl;
                system("PAUSE");
        return 1;
    } catch (...) {
        std::cerr << "unknown error" << std::endl;
                system("PAUSE");
        return 1;
    }
}

-------------

Best and thx
Chris

-----Ursprüngliche Nachricht-----
Von: Luigi Ballabio [mailto:[hidden email]]
Gesendet: Mittwoch, 23. Oktober 2013 18:08
An: Breig, Dr. Christoph (IDS GmbH)
Cc: QuantLib developers
Betreff: Re: [Quantlib-dev] RelinkableHandle<YieldTermStructure> reset to Null

It looks like the spreaded curve notifies its observers of the change,
one of them tries to perform some calculation as a consequence, and
the calculation fails because the handle is empty.  Can you reproduce
the problem in a short program you can post?

Luigi


On Wed, Oct 23, 2013 at 4:49 PM, Breig, Dr. Christoph (IDS GmbH)
<[hidden email]> wrote:

> Hi Luigi, hi all
>
> the empty shared_ptr works fine for e.g. InterpolatedZeroCurves but not for
> ZeroSpreadedTermStructures. Then, while setting the empty shared_ptr,
> following error messages takes place:
> "could not notify one or more observers: empty Handle cannot be
> dereferenced"
>
> I'm at the moment using version 1.0 of QuantLib (in case the problem is a
> bug and was already fixed).
>
> Best and thanks
> Chris
>
> ________________________________
> Von: Luigi Ballabio [mailto:[hidden email]]
> Gesendet: Freitag, 18. Oktober 2013 16:13
> An: Breig, Dr. Christoph (IDS GmbH)
> Cc: QuantLib developers
> Betreff: Re: [Quantlib-dev] RelinkableHandle<YieldTermStructure> reset to
> Null
>
> Hi,
>     link it to an empty shared_ptr.
>
> Luigi
>
> On Oct 18, 2013 4:01 PM, "Breig, Dr. Christoph (IDS GmbH)"
> <[hidden email]> wrote:
>>
>> Dear all,
>>
>> has anybody an idea how to set a Relinkable Handle who is already linked
>> to a YieldTermStructure object back to Null, so that the function
>> "empty()" returns again true?
>>
>> Best and thanks
>> Chris
>>
>>
>> ------------------------------------------------------------------------------
>> October Webinars: Code for Performance
>> Free Intel webinars can help you accelerate application performance.
>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
>> from
>> the latest Intel processors and coprocessors. See abstracts and register >
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
>> _______________________________________________
>> QuantLib-dev mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/quantlib-dev
>>
>



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

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev