//-------------------------------------------------------------------------
        public virtual void coverage()
        {
            IborCapFloorLeg test1 = IborCapFloorLeg.builder().calculation(RATE_CALCULATION).floorSchedule(FLOOR).notional(NOTIONAL).paymentSchedule(SCHEDULE).payReceive(RECEIVE).build();

            coverImmutableBean(test1);
            IborCapFloorLeg test2 = IborCapFloorLeg.builder().calculation(IborRateCalculation.of(GBP_LIBOR_6M)).capSchedule(CAP).notional(ValueSchedule.of(1000)).paymentDateOffset(PAYMENT_OFFSET).paymentSchedule(PeriodicSchedule.builder().startDate(START).endDate(END).frequency(Frequency.P6M).businessDayAdjustment(BUSS_ADJ).build()).payReceive(PAY).build();

            coverBeanEquals(test1, test2);
        }
 public virtual void test_builder_fail()
 {
     // cap and floor present
     assertThrowsIllegalArg(() => IborCapFloorLeg.builder().calculation(RATE_CALCULATION).capSchedule(CAP).floorSchedule(FLOOR).notional(NOTIONAL).paymentSchedule(SCHEDULE).payReceive(RECEIVE).build());
     // cap and floor missing
     assertThrowsIllegalArg(() => IborCapFloorLeg.builder().calculation(RATE_CALCULATION).notional(NOTIONAL).paymentSchedule(PeriodicSchedule.builder().startDate(START).endDate(END).frequency(FREQUENCY).businessDayAdjustment(BUSS_ADJ).build()).payReceive(RECEIVE).build());
     // stub type
     assertThrowsIllegalArg(() => IborCapFloorLeg.builder().calculation(RATE_CALCULATION).capSchedule(CAP).currency(GBP).notional(NOTIONAL).paymentDateOffset(PAYMENT_OFFSET).paymentSchedule(PeriodicSchedule.builder().startDate(START).endDate(END).frequency(FREQUENCY).businessDayAdjustment(BUSS_ADJ).stubConvention(StubConvention.SHORT_FINAL).build()).payReceive(PAY).build());
 }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            IborCapFloor test1 = IborCapFloor.of(CAPFLOOR_LEG);

            coverImmutableBean(test1);
            IborCapFloorLeg capFloor = IborCapFloorLeg.builder().calculation(RATE_CALCULATION).floorSchedule(CAP).notional(NOTIONAL).paymentDateOffset(PAYMENT_OFFSET).paymentSchedule(SCHEDULE).payReceive(RECEIVE).build();
            IborCapFloor    test2    = IborCapFloor.of(capFloor, PAY_LEG);

            coverBeanEquals(test1, test2);
        }
Esempio n. 4
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            IborCapFloorTrade test1 = sut();

            coverImmutableBean(test1);
            IborCapFloor      product = IborCapFloor.of(IborCapFloorLeg.builder().calculation(RATE_CALCULATION).floorSchedule(CAP).notional(NOTIONAL).paymentDateOffset(PAYMENT_OFFSET).paymentSchedule(SCHEDULE).payReceive(PAY).build());
            IborCapFloorTrade test2   = IborCapFloorTrade.builder().product(product).build();

            coverBeanEquals(test1, test2);
        }
        public virtual void test_builder_min()
        {
            IborCapFloorLeg test = IborCapFloorLeg.builder().calculation(RATE_CALCULATION).floorSchedule(FLOOR).notional(NOTIONAL).paymentSchedule(SCHEDULE).payReceive(RECEIVE).build();

            assertEquals(test.Calculation, RATE_CALCULATION);
            assertEquals(test.CapSchedule.Present, false);
            assertEquals(test.FloorSchedule.get(), FLOOR);
            assertEquals(test.Currency, EUR);
            assertEquals(test.Notional, NOTIONAL);
            assertEquals(test.PaymentDateOffset, DaysAdjustment.NONE);
            assertEquals(test.PaymentSchedule, SCHEDULE);
            assertEquals(test.PayReceive, RECEIVE);
            assertEquals(test.StartDate, AdjustableDate.of(START, BUSS_ADJ));
            assertEquals(test.EndDate, AdjustableDate.of(END, BUSS_ADJ));
        }
        public virtual void test_builder_full()
        {
            IborCapFloorLeg test = IborCapFloorLeg.builder().calculation(RATE_CALCULATION).capSchedule(CAP).currency(GBP).notional(NOTIONAL).paymentDateOffset(PAYMENT_OFFSET).paymentSchedule(SCHEDULE).payReceive(PAY).build();

            assertEquals(test.Calculation, RATE_CALCULATION);
            assertEquals(test.CapSchedule.get(), CAP);
            assertEquals(test.FloorSchedule.Present, false);
            assertEquals(test.Currency, GBP);
            assertEquals(test.Notional, NOTIONAL);
            assertEquals(test.PaymentDateOffset, PAYMENT_OFFSET);
            assertEquals(test.PaymentSchedule, SCHEDULE);
            assertEquals(test.PayReceive, PAY);
            assertEquals(test.StartDate, AdjustableDate.of(START, BUSS_ADJ));
            assertEquals(test.EndDate, AdjustableDate.of(END, BUSS_ADJ));
            assertEquals(test.Index, EUR_EURIBOR_3M);
        }
        public virtual void test_resolve_floor()
        {
            IborCapFloorLeg @base = IborCapFloorLeg.builder().calculation(RATE_CALCULATION).floorSchedule(FLOOR).currency(GBP).notional(NOTIONAL).paymentDateOffset(PAYMENT_OFFSET).paymentSchedule(SCHEDULE).payReceive(PAY).build();

            LocalDate[] unadjustedDates        = new LocalDate[] { START, START.plusMonths(3), START.plusMonths(6), START.plusMonths(9), START.plusMonths(12) };
            IborCapletFloorletPeriod[] periods = new IborCapletFloorletPeriod[4];
            for (int i = 0; i < 4; ++i)
            {
                LocalDate start        = BUSS_ADJ.adjust(unadjustedDates[i], REF_DATA);
                LocalDate end          = BUSS_ADJ.adjust(unadjustedDates[i + 1], REF_DATA);
                double    yearFraction = EUR_EURIBOR_3M.DayCount.relativeYearFraction(start, end);
                LocalDate fixingDate   = RATE_CALCULATION.FixingDateOffset.adjust(start, REF_DATA);
                periods[i] = IborCapletFloorletPeriod.builder().floorlet(STRIKES[i]).currency(GBP).startDate(start).endDate(end).unadjustedStartDate(unadjustedDates[i]).unadjustedEndDate(unadjustedDates[i + 1]).paymentDate(PAYMENT_OFFSET.adjust(end, REF_DATA)).notional(-NOTIONALS[i]).iborRate(IborRateComputation.of(EUR_EURIBOR_3M, fixingDate, REF_DATA)).yearFraction(yearFraction).build();
            }
            ResolvedIborCapFloorLeg expected = ResolvedIborCapFloorLeg.builder().capletFloorletPeriods(periods).payReceive(PAY).build();
            ResolvedIborCapFloorLeg computed = @base.resolve(REF_DATA);

            assertEquals(computed, expected);
        }
        public virtual void test_resolve_cap()
        {
            IborRateCalculation rateCalc = IborRateCalculation.builder().index(EUR_EURIBOR_3M).fixingRelativeTo(FixingRelativeTo.PERIOD_END).fixingDateOffset(EUR_EURIBOR_3M.FixingDateOffset).build();
            IborCapFloorLeg     @base    = IborCapFloorLeg.builder().calculation(rateCalc).capSchedule(CAP).notional(NOTIONAL).paymentDateOffset(PAYMENT_OFFSET).paymentSchedule(SCHEDULE).payReceive(RECEIVE).build();

            LocalDate[] unadjustedDates        = new LocalDate[] { START, START.plusMonths(3), START.plusMonths(6), START.plusMonths(9), START.plusMonths(12) };
            IborCapletFloorletPeriod[] periods = new IborCapletFloorletPeriod[4];
            for (int i = 0; i < 4; ++i)
            {
                LocalDate start        = BUSS_ADJ.adjust(unadjustedDates[i], REF_DATA);
                LocalDate end          = BUSS_ADJ.adjust(unadjustedDates[i + 1], REF_DATA);
                double    yearFraction = EUR_EURIBOR_3M.DayCount.relativeYearFraction(start, end);
                periods[i] = IborCapletFloorletPeriod.builder().caplet(CAP.InitialValue).currency(EUR).startDate(start).endDate(end).unadjustedStartDate(unadjustedDates[i]).unadjustedEndDate(unadjustedDates[i + 1]).paymentDate(PAYMENT_OFFSET.adjust(end, REF_DATA)).notional(NOTIONALS[i]).iborRate(IborRateComputation.of(EUR_EURIBOR_3M, rateCalc.FixingDateOffset.adjust(end, REF_DATA), REF_DATA)).yearFraction(yearFraction).build();
            }
            ResolvedIborCapFloorLeg expected = ResolvedIborCapFloorLeg.builder().capletFloorletPeriods(periods).payReceive(RECEIVE).build();
            ResolvedIborCapFloorLeg computed = @base.resolve(REF_DATA);

            assertEquals(computed, expected);
        }
        public virtual void test_serialization()
        {
            IborCapFloorLeg test = IborCapFloorLeg.builder().calculation(RATE_CALCULATION).floorSchedule(FLOOR).notional(NOTIONAL).paymentSchedule(SCHEDULE).payReceive(RECEIVE).build();

            assertSerialization(test);
        }