Re: C# Error when trying to price instrument 'System.ApplicationException : 2nd leg: empty Handle cannot be dereferenced'

Posted by Luigi Ballabio on
URL: http://quantlib.414.s1.nabble.com/C-Error-when-trying-to-price-instrument-System-ApplicationException-2nd-leg-empty-Handle-cannot-be-d-tp8585p8587.html

On Wed, 2010-10-27 at 11:51 +0200, Ahmad Mahomed wrote:
> 1) The actual error is being thrown from the
> `discountingswapengine.cpp` calculate routine specifically around
> these lines. The fact that the error is showing 2nd leg implies to me
> that the loop fails at the second iteration (there should be only two
> loops since there are only two legs). The only code here that deals
> with Handles and pointers  from what I gather relate to  the
> 'discountCurve_'.

No, the discount curve seems fine (or the engine would blow at the first
iteration.)  My guess is that you don't pass to your Jibar index the
risk-free curve:

>                     VanillaSwap impliedSwap = new VanillaSwap(
>                         _VanillaSwap.Type.Payer,
>                         10000000.0,
>                         fixedSchedule,
>                         0.1,
>                         Actual365FixedDayCounter,
>                         floatSchedule,
>                         new Jibar(new Period(Frequency.Quarterly)),
>                         0,
>                         Actual365FixedDayCounter);

without a term structure, the Jibar above can return past fixings but
not forecast future ones.  If you replace the Jibar constructor above
with

new Jibar(new Period(Frequency.Quarterly), DiscountingTermStructure)

it might work (unless there are other similar places in the code that
we're not seeing...)

Luigi


--

The idea that an arbitrary naive human should be able to properly
use a given tool without training or understanding is even more
wrong for computing than it is for other tools (e.g. automobiles,
airplanes, guns, power saws).
-- Doug Gwyn



------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users