Re: Fixed bond - Empty Handle cannot be dereferenced

Posted by Luigi Ballabio on
URL: http://quantlib.414.s1.nabble.com/Fixed-bond-Empty-Handle-cannot-be-dereferenced-tp7595p7596.html

On Mon, 2009-07-06 at 12:22 +0200, Bogaert, Gilles wrote:

> I am trying to calculate the NPV of a straight bond. I instantiated
> the yield curve and I relinked it to discountingTermStructure. But
> when I call fixedRateBond.NPV(), I got this message “empty Handle
> cannot be dereferenced”. Here is the code:
>
>  
>
> boost::shared_ptr<YieldTermStructure> depoSwapTermStructure(
>
>                                                                 new
> PiecewiseYieldCurve<Discount,LogLinear>(
>
>
> settlementDate, depoSwapInstruments,
>
>
> termStructureDayCounter,
>
>
> std::vector<Handle<Quote> >(),
>
>
> std::vector<Date>(),
>
>
> tolerance));
>
> RelinkableHandle<YieldTermStructure> discountingTermStructure;
>
> boost::shared_ptr<PricingEngine> bondEngine(
>
>                                                                 new
> DiscountingBondEngine(discountingTermStructure));
>
> fixedRateBond.setPricingEngine(bondEngine);
>
> std::cout << fixedRateBond.NPV() << std::endl;

You're not linking the depo-swap curve to the handle in the above code.

Luigi


--

The nice thing about standards is that there are so many of them to
choose from.
-- Andrew S. Tanenbaum



------------------------------------------------------------------------------
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users