Example #1
0
        public virtual void test_of()
        {
            FixedCouponBondPaymentPeriod test = FixedCouponBondPaymentPeriod.builder().currency(USD).startDate(START_ADJUSTED).unadjustedStartDate(START).endDate(END_ADJUSTED).unadjustedEndDate(END).detachmentDate(DETACHMENT_DATE).notional(NOTIONAL).fixedRate(FIXED_RATE).yearFraction(YEAR_FRACTION).build();

            assertEquals(test.Currency, USD);
            assertEquals(test.UnadjustedStartDate, START);
            assertEquals(test.StartDate, START_ADJUSTED);
            assertEquals(test.UnadjustedEndDate, END);
            assertEquals(test.EndDate, END_ADJUSTED);
            assertEquals(test.PaymentDate, END_ADJUSTED);
            assertEquals(test.DetachmentDate, DETACHMENT_DATE);
            assertEquals(test.FixedRate, FIXED_RATE);
            assertEquals(test.Notional, NOTIONAL);
            assertEquals(test.YearFraction, YEAR_FRACTION);
            assertEquals(test.hasExCouponPeriod(), true);

            // the object is not changed
            assertEquals(test.adjustPaymentDate(TemporalAdjusters.ofDateAdjuster(d => d.plusDays(2))), test);
            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(test.Currency, USD);
            assertEquals(test.UnadjustedStartDate, START);
            assertEquals(test.StartDate, START_ADJUSTED);
            assertEquals(test.UnadjustedEndDate, END);
            assertEquals(test.EndDate, END_ADJUSTED);
            assertEquals(test.PaymentDate, END_ADJUSTED);
            assertEquals(test.DetachmentDate, DETACHMENT_DATE);
            assertEquals(test.FixedRate, FIXED_RATE);
            assertEquals(test.Notional, NOTIONAL);
            assertEquals(test.YearFraction, YEAR_FRACTION);
            assertEquals(test.hasExCouponPeriod(), true);
        }
Example #2
0
        //-------------------------------------------------------------------------
        public virtual void test_adjustDate()
        {
            Payment test     = Payment.ofReceive(GBP_P1000, DATE_2015_06_29);
            Payment expected = Payment.of(GBP_P1000, DATE_2015_06_29.plusDays(1));

            assertEquals(test.adjustDate(TemporalAdjusters.ofDateAdjuster(d => d.plusDays(1))), expected);
        }
        //-------------------------------------------------------------------------
        public virtual void test_adjustPaymentDate()
        {
            KnownAmountSwapPaymentPeriod test     = KnownAmountSwapPaymentPeriod.builder().payment(PAYMENT_2014_10_01).startDate(DATE_2014_03_30).unadjustedStartDate(DATE_2014_03_30).endDate(DATE_2014_10_01).unadjustedEndDate(DATE_2014_09_30).build();
            KnownAmountSwapPaymentPeriod expected = KnownAmountSwapPaymentPeriod.builder().payment(PAYMENT_2014_10_03).startDate(DATE_2014_03_30).unadjustedStartDate(DATE_2014_03_30).endDate(DATE_2014_10_01).unadjustedEndDate(DATE_2014_09_30).build();

            assertEquals(test.adjustPaymentDate(TemporalAdjusters.ofDateAdjuster(d => d.plusDays(0))), test);
            assertEquals(test.adjustPaymentDate(TemporalAdjusters.ofDateAdjuster(d => d.plusDays(2))), expected);
        }
Example #4
0
        //-------------------------------------------------------------------------
        public virtual void test_adjustPaymentDate()
        {
            FxResetNotionalExchange test     = FxResetNotionalExchange.of(CurrencyAmount.of(USD, 1000d), DATE_2014_06_30, FxIndexObservation.of(GBP_USD_WM, DATE_2014_03_28, REF_DATA));
            FxResetNotionalExchange expected = FxResetNotionalExchange.of(CurrencyAmount.of(USD, 1000d), DATE_2014_06_30.plusDays(2), FxIndexObservation.of(GBP_USD_WM, DATE_2014_03_28, REF_DATA));

            assertEquals(test.adjustPaymentDate(TemporalAdjusters.ofDateAdjuster(d => d.plusDays(0))), test);
            assertEquals(test.adjustPaymentDate(TemporalAdjusters.ofDateAdjuster(d => d.plusDays(2))), expected);
        }
Example #5
0
        //-------------------------------------------------------------------------
        public virtual void test_adjustPaymentDate()
        {
            RatePaymentPeriod test     = RatePaymentPeriod.builder().paymentDate(DATE_2014_10_01).accrualPeriods(RAP2).dayCount(ACT_365F).currency(GBP).notional(1000d).compoundingMethod(CompoundingMethod.STRAIGHT).build();
            RatePaymentPeriod expected = RatePaymentPeriod.builder().paymentDate(DATE_2014_10_01.plusDays(2)).accrualPeriods(RAP2).dayCount(ACT_365F).currency(GBP).notional(1000d).compoundingMethod(CompoundingMethod.STRAIGHT).build();

            assertEquals(test.adjustPaymentDate(TemporalAdjusters.ofDateAdjuster(d => d.plusDays(0))), test);
            assertEquals(test.adjustPaymentDate(TemporalAdjusters.ofDateAdjuster(d => d.plusDays(2))), expected);
        }
        //-------------------------------------------------------------------------
        public virtual void test_adjustPaymentDate()
        {
            NotionalExchange test     = NotionalExchange.of(GBP_1000, DATE_2014_06_30);
            NotionalExchange expected = NotionalExchange.of(GBP_1000, DATE_2014_06_30.plusDays(2));

            assertEquals(test.adjustPaymentDate(TemporalAdjusters.ofDateAdjuster(d => d.plusDays(0))), test);
            assertEquals(test.adjustPaymentDate(TemporalAdjusters.ofDateAdjuster(d => d.plusDays(2))), expected);
        }
        public virtual void test_methods()
        {
            CapitalIndexedBondPaymentPeriod test = CapitalIndexedBondPaymentPeriod.builder().currency(USD).notional(NOTIONAL).detachmentDate(DETACHMENT).startDate(START).endDate(END).unadjustedStartDate(START_UNADJ).unadjustedEndDate(END_UNADJ).rateComputation(COMPUTE_INTERP).realCoupon(REAL_COUPON).build();

            assertEquals(test.PaymentDate, END);
            assertEquals(test.adjustPaymentDate(TemporalAdjusters.ofDateAdjuster(d => d.plusDays(2))), test);
            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            ImmutableSet <Index> set = builder.build();

            assertEquals(set.size(), 1);
            assertEquals(set.asList().get(0), US_CPI_U);

            LocalDate bondStart      = LocalDate.of(2003, 1, 13);
            LocalDate bondStartUnadj = LocalDate.of(2003, 1, 12);
            CapitalIndexedBondPaymentPeriod expected = CapitalIndexedBondPaymentPeriod.builder().currency(USD).notional(NOTIONAL).detachmentDate(END).startDate(bondStart).endDate(END).unadjustedStartDate(bondStartUnadj).unadjustedEndDate(END_UNADJ).rateComputation(COMPUTE_INTERP).realCoupon(1d).build();

            assertEquals(test.withUnitCoupon(bondStart, bondStartUnadj), expected);
        }
Example #8
0
        public virtual void test_adjustDate_noChange()
        {
            Payment test = Payment.ofReceive(GBP_P1000, DATE_2015_06_29);

            assertSame(test.adjustDate(TemporalAdjusters.ofDateAdjuster(d => d.plusDays(1).minusDays(1))), test);
        }