示例#1
0
 public ZeroCouponInflationSwap(ZeroCouponInflationSwap.Type type, double nominal, Date start, Date maturity, Calendar calendar, BusinessDayConvention convention, DayCounter dayCounter, double fixedRate, ZeroInflationIndex index, Period lag) : this(NQuantLibcPINVOKE.new_ZeroCouponInflationSwap__SWIG_3((int)type, nominal, Date.getCPtr(start), Date.getCPtr(maturity), Calendar.getCPtr(calendar), (int)convention, DayCounter.getCPtr(dayCounter), fixedRate, ZeroInflationIndex.getCPtr(index), Period.getCPtr(lag)), true)
 {
     if (NQuantLibcPINVOKE.SWIGPendingException.Pending)
     {
         throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
     }
 }
示例#2
0
 public ZeroCouponInflationSwap.Type type()
 {
     ZeroCouponInflationSwap.Type ret = (ZeroCouponInflationSwap.Type)NQuantLibcPINVOKE.ZeroCouponInflationSwap_type(swigCPtr);
     if (NQuantLibcPINVOKE.SWIGPendingException.Pending)
     {
         throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
     }
     return(ret);
 }
示例#3
0
        public void zciisconsistency()
        {
            CommonVars common = new CommonVars();

            ZeroCouponInflationSwap.Type ztype = ZeroCouponInflationSwap.Type.Payer;
            double   nominal   = 1000000.0;
            Date     startDate = new Date(common.evaluationDate);
            Date     endDate   = new Date(25, Month.November, 2059);
            Calendar cal       = new UnitedKingdom();
            BusinessDayConvention paymentConvention = BusinessDayConvention.ModifiedFollowing;
            DayCounter            dummyDC = null, dc = new ActualActual();
            Period observationLag = new Period(2, TimeUnit.Months);

            double quote          = 0.03714;
            ZeroCouponInflationSwap zciis = new ZeroCouponInflationSwap(ztype, nominal, startDate, endDate, cal,
                                                                        paymentConvention, dc, quote, common.ii, observationLag);

            // simple structure so simple pricing engine - most work done by index
            DiscountingSwapEngine dse = new DiscountingSwapEngine(common.nominalUK);

            zciis.setPricingEngine(dse);
            QAssert.IsTrue(Math.Abs(zciis.NPV()) < 1e-3, "zciis does not reprice to zero");

            List <Date> oneDate = new List <Date>();

            oneDate.Add(endDate);
            Schedule schOneDate = new Schedule(oneDate, cal, paymentConvention);

            CPISwap.Type stype = CPISwap.Type.Payer;
            double       inflationNominal = nominal;
            double       floatNominal = inflationNominal * Math.Pow(1.0 + quote, 50);
            bool         subtractInflationNominal = true;
            double       dummySpread = 0.0, dummyFixedRate = 0.0;
            int          fixingDays = 0;
            Date         baseDate   = startDate - observationLag;
            double       baseCPI    = common.ii.fixing(baseDate);

            IborIndex dummyFloatIndex = new IborIndex();

            CPISwap cS = new CPISwap(stype, floatNominal, subtractInflationNominal, dummySpread, dummyDC, schOneDate,
                                     paymentConvention, fixingDays, dummyFloatIndex,
                                     dummyFixedRate, baseCPI, dummyDC, schOneDate, paymentConvention, observationLag,
                                     common.ii, InterpolationType.AsIndex, inflationNominal);

            cS.setPricingEngine(dse);
            QAssert.IsTrue(Math.Abs(cS.NPV()) < 1e-3, "CPISwap as ZCIIS does not reprice to zero");

            for (int i = 0; i < 2; i++)
            {
                double cs = cS.legNPV(i).GetValueOrDefault();
                double z  = zciis.legNPV(i).GetValueOrDefault();
                QAssert.IsTrue(Math.Abs(cs - z) < 1e-3, "zciis leg does not equal CPISwap leg");
            }
            // remove circular refernce
            common.hcpi.linkTo(null);
        }