Exemplo n.º 1
0
        public virtual void test_createSchedule_dualStub()
        {
            PaymentSchedule test     = PaymentSchedule.builder().paymentFrequency(P2M).paymentDateOffset(DaysAdjustment.ofBusinessDays(2, GBLO)).build();
            Schedule        schedule = test.createSchedule(ACCRUAL_SCHEDULE_STUBS, REF_DATA);

            assertEquals(schedule, ACCRUAL_SCHEDULE_STUBS.toBuilder().frequency(P2M).build());
        }
Exemplo n.º 2
0
        public virtual void test_createSchedule_term()
        {
            PaymentSchedule test     = PaymentSchedule.builder().paymentFrequency(TERM).paymentDateOffset(DaysAdjustment.ofBusinessDays(2, GBLO)).build();
            Schedule        schedule = test.createSchedule(ACCRUAL_SCHEDULE, REF_DATA);

            assertEquals(schedule, ACCRUAL_SCHEDULE_TERM);
        }
Exemplo n.º 3
0
        public virtual void test_resolve()
        {
            FixedCouponBond         @base    = sut();
            ResolvedFixedCouponBond resolved = @base.resolve(REF_DATA);

            assertEquals(resolved.LegalEntityId, LEGAL_ENTITY);
            assertEquals(resolved.SettlementDateOffset, DATE_OFFSET);
            assertEquals(resolved.YieldConvention, YIELD_CONVENTION);
            ImmutableList <FixedCouponBondPaymentPeriod> periodicPayments = resolved.PeriodicPayments;
            int expNum = 20;

            assertEquals(periodicPayments.size(), expNum);
            LocalDate unadjustedEnd = END_DATE;
            Schedule  unadjusted    = PERIOD_SCHEDULE.createSchedule(REF_DATA).toUnadjusted();

            for (int i = 0; i < expNum; ++i)
            {
                FixedCouponBondPaymentPeriod payment = periodicPayments.get(expNum - 1 - i);
                assertEquals(payment.Currency, EUR);
                assertEquals(payment.Notional, NOTIONAL);
                assertEquals(payment.FixedRate, FIXED_RATE);
                assertEquals(payment.UnadjustedEndDate, unadjustedEnd);
                assertEquals(payment.EndDate, BUSINESS_ADJUST.adjust(unadjustedEnd, REF_DATA));
                assertEquals(payment.PaymentDate, payment.EndDate);
                LocalDate unadjustedStart = unadjustedEnd.minusMonths(6);
                assertEquals(payment.UnadjustedStartDate, unadjustedStart);
                assertEquals(payment.StartDate, BUSINESS_ADJUST.adjust(unadjustedStart, REF_DATA));
                assertEquals(payment.YearFraction, unadjusted.getPeriod(expNum - 1 - i).yearFraction(DAY_COUNT, unadjusted));
                assertEquals(payment.DetachmentDate, EX_COUPON.adjust(payment.PaymentDate, REF_DATA));
                unadjustedEnd = unadjustedStart;
            }
            Payment expectedPayment = Payment.of(CurrencyAmount.of(EUR, NOTIONAL), BUSINESS_ADJUST.adjust(END_DATE, REF_DATA));

            assertEquals(resolved.NominalPayment, expectedPayment);
        }
Exemplo n.º 4
0
        public virtual void test_createSchedule_lastDate_finalAccrualStub()
        {
            PaymentSchedule test     = PaymentSchedule.builder().paymentFrequency(P2M).paymentDateOffset(DaysAdjustment.ofBusinessDays(2, GBLO)).lastRegularEndDate(DATE_03_05).build();
            Schedule        schedule = test.createSchedule(ACCRUAL_SCHEDULE_FINAL_STUB_4PERIODS, REF_DATA);
            Schedule        expected = Schedule.builder().periods(SchedulePeriod.of(DATE_01_06, DATE_03_05, DATE_01_05, DATE_03_05), SchedulePeriod.of(DATE_03_05, DATE_04_30, DATE_03_05, DATE_04_30)).frequency(P2M).rollConvention(DAY_5).build();

            assertEquals(schedule, expected);
        }
Exemplo n.º 5
0
        public virtual void test_createSchedule_firstDate_validInitialStub()
        {
            PaymentSchedule test     = PaymentSchedule.builder().paymentFrequency(P2M).paymentDateOffset(DaysAdjustment.ofBusinessDays(2, GBLO)).firstRegularStartDate(DATE_02_05).build();
            Schedule        schedule = test.createSchedule(ACCRUAL_SCHEDULE, REF_DATA);
            Schedule        expected = Schedule.builder().periods(SchedulePeriod.of(DATE_01_06, DATE_02_05, DATE_01_05, DATE_02_05), SchedulePeriod.of(DATE_02_05, DATE_04_07, DATE_02_05, DATE_04_05)).frequency(P2M).rollConvention(DAY_5).build();

            assertEquals(schedule, expected);
        }
Exemplo n.º 6
0
        public virtual void test_createSchedule_finalStubFullMerge()
        {
            PaymentSchedule test     = PaymentSchedule.builder().paymentFrequency(P2M).paymentDateOffset(DaysAdjustment.ofBusinessDays(2, GBLO)).build();
            Schedule        schedule = test.createSchedule(ACCRUAL_SCHEDULE_FINAL_STUB, REF_DATA);
            Schedule        expected = Schedule.builder().periods(SchedulePeriod.of(DATE_01_06, DATE_03_05, DATE_01_05, DATE_03_05), ACCRUAL3STUB).frequency(P2M).rollConvention(DAY_5).build();

            assertEquals(schedule, expected);
        }
Exemplo n.º 7
0
        public virtual void test_createSchedule_initialStubPartMergeBackwards()
        {
            PaymentSchedule test     = PaymentSchedule.builder().paymentFrequency(P2M).paymentDateOffset(DaysAdjustment.ofBusinessDays(2, GBLO)).build();
            Schedule        schedule = test.createSchedule(ACCRUAL_SCHEDULE_INITIAL_STUB, REF_DATA);
            Schedule        expected = Schedule.builder().periods(ACCRUAL1STUB, SchedulePeriod.of(DATE_02_05, DATE_03_05, DATE_02_05, DATE_03_05), SchedulePeriod.of(DATE_03_05, DATE_05_06, DATE_03_05, DATE_05_05)).frequency(P2M).rollConvention(DAY_5).build();

            assertEquals(schedule, expected);
        }
        //-------------------------------------------------------------------------
        public virtual void test_resolve()
        {
            ResetSchedule  test          = ResetSchedule.builder().resetFrequency(P1M).businessDayAdjustment(BusinessDayAdjustment.of(FOLLOWING, GBLO)).build();
            SchedulePeriod accrualPeriod = SchedulePeriod.of(DATE_01_06, DATE_04_07, DATE_01_05, DATE_04_05);
            Schedule       schedule      = test.createSchedule(DAY_5, REF_DATA).apply(accrualPeriod);
            Schedule       expected      = Schedule.builder().periods(SchedulePeriod.of(DATE_01_06, DATE_02_05, DATE_01_05, DATE_02_05), SchedulePeriod.of(DATE_02_05, DATE_03_05, DATE_02_05, DATE_03_05), SchedulePeriod.of(DATE_03_05, DATE_04_07, DATE_03_05, DATE_04_05)).frequency(P1M).rollConvention(DAY_5).build();

            assertEquals(schedule, expected);
        }
        public virtual void test_expand_distinctValues()
        {
            FixedRateCalculation test                 = FixedRateCalculation.builder().dayCount(ACT_365F).rate(ValueSchedule.of(0.025d, ValueStep.of(1, ValueAdjustment.ofReplace(0.020d)), ValueStep.of(2, ValueAdjustment.ofReplace(0.015d)))).build();
            SchedulePeriod       period1              = SchedulePeriod.of(date(2014, 1, 6), date(2014, 2, 5), date(2014, 1, 5), date(2014, 2, 5));
            SchedulePeriod       period2              = SchedulePeriod.of(date(2014, 1, 5), date(2014, 2, 5), date(2014, 2, 5), date(2014, 3, 5));
            SchedulePeriod       period3              = SchedulePeriod.of(date(2014, 3, 5), date(2014, 4, 7), date(2014, 3, 5), date(2014, 4, 5));
            Schedule             schedule             = Schedule.builder().periods(period1, period2, period3).frequency(Frequency.P1M).rollConvention(RollConventions.DAY_5).build();
            RateAccrualPeriod    rap1                 = RateAccrualPeriod.builder(period1).yearFraction(period1.yearFraction(ACT_365F, schedule)).rateComputation(FixedRateComputation.of(0.025d)).build();
            RateAccrualPeriod    rap2                 = RateAccrualPeriod.builder(period2).yearFraction(period2.yearFraction(ACT_365F, schedule)).rateComputation(FixedRateComputation.of(0.020d)).build();
            RateAccrualPeriod    rap3                 = RateAccrualPeriod.builder(period3).yearFraction(period3.yearFraction(ACT_365F, schedule)).rateComputation(FixedRateComputation.of(0.015d)).build();
            ImmutableList <RateAccrualPeriod> periods = test.createAccrualPeriods(schedule, schedule, REF_DATA);

            assertEquals(periods, ImmutableList.of(rap1, rap2, rap3));
        }
        public virtual void test_expand_initialStubAndResetPeriods_weighted_firstFixed()
        {
            IborRateCalculation test = IborRateCalculation.builder().dayCount(ACT_360).index(GBP_LIBOR_3M).fixingDateOffset(MINUS_TWO_DAYS).resetPeriods(ResetSchedule.builder().resetFrequency(P1M).businessDayAdjustment(BusinessDayAdjustment.of(FOLLOWING, GBLO)).resetMethod(WEIGHTED).build()).firstRegularRate(0.028d).initialStub(IborRateStubCalculation.ofFixedRate(0.030d)).build();

            SchedulePeriod accrual1 = SchedulePeriod.of(DATE_02_05, DATE_04_07, DATE_02_05, DATE_04_05);
            SchedulePeriod accrual2 = SchedulePeriod.of(DATE_04_07, DATE_07_07, DATE_04_05, DATE_07_05);
            Schedule       schedule = Schedule.builder().periods(accrual1, accrual2).frequency(P3M).rollConvention(DAY_5).build();

            RateAccrualPeriod    rap1 = RateAccrualPeriod.builder(accrual1).yearFraction(accrual1.yearFraction(ACT_360, schedule)).rateComputation(FixedRateComputation.of(0.030d)).build();
            IborIndexObservation obs4 = IborIndexObservation.of(GBP_LIBOR_3M, DATE_04_03, REF_DATA);
            IborIndexObservation obs5 = IborIndexObservation.of(GBP_LIBOR_3M, DATE_05_01, REF_DATA);
            IborIndexObservation obs6 = IborIndexObservation.of(GBP_LIBOR_3M, DATE_06_03, REF_DATA);
            ImmutableList <IborAveragedFixing> fixings2 = ImmutableList.of(IborAveragedFixing.ofDaysInResetPeriod(obs4, DATE_04_07, DATE_05_06, 0.028d), IborAveragedFixing.ofDaysInResetPeriod(obs5, DATE_05_06, DATE_06_05), IborAveragedFixing.ofDaysInResetPeriod(obs6, DATE_06_05, DATE_07_07));
            RateAccrualPeriod rap2 = RateAccrualPeriod.builder(accrual2).yearFraction(accrual2.yearFraction(ACT_360, schedule)).rateComputation(IborAveragedRateComputation.of(fixings2)).build();
            ImmutableList <RateAccrualPeriod> periods = test.createAccrualPeriods(schedule, schedule, REF_DATA);

            assertEquals(periods, ImmutableList.of(rap1, rap2));
        }
        public virtual void test_expand_resetPeriods_weighted_firstFixingDateOffset()
        {
            // only the fixing date of the first reset period is changed, everything else stays the same
            IborRateCalculation test = IborRateCalculation.builder().dayCount(ACT_365F).index(GBP_LIBOR_3M).fixingDateOffset(MINUS_TWO_DAYS).resetPeriods(ResetSchedule.builder().resetFrequency(P1M).businessDayAdjustment(BusinessDayAdjustment.of(FOLLOWING, GBLO)).resetMethod(WEIGHTED).build()).firstFixingDateOffset(MINUS_ONE_DAY).build();

            SchedulePeriod accrual1 = SchedulePeriod.of(DATE_01_06, DATE_04_07, DATE_01_05, DATE_04_05);
            SchedulePeriod accrual2 = SchedulePeriod.of(DATE_04_07, DATE_07_07, DATE_04_05, DATE_07_05);
            Schedule       schedule = Schedule.builder().periods(accrual1, accrual2).frequency(P3M).rollConvention(DAY_5).build();

            IborIndexObservation obs1 = IborIndexObservation.of(GBP_LIBOR_3M, DATE_01_03, REF_DATA);
            IborIndexObservation obs2 = IborIndexObservation.of(GBP_LIBOR_3M, DATE_02_03, REF_DATA);
            IborIndexObservation obs3 = IborIndexObservation.of(GBP_LIBOR_3M, DATE_03_03, REF_DATA);
            ImmutableList <IborAveragedFixing> fixings1 = ImmutableList.of(IborAveragedFixing.ofDaysInResetPeriod(obs1, DATE_01_06, DATE_02_05), IborAveragedFixing.ofDaysInResetPeriod(obs2, DATE_02_05, DATE_03_05), IborAveragedFixing.ofDaysInResetPeriod(obs3, DATE_03_05, DATE_04_07));
            RateAccrualPeriod rap1 = RateAccrualPeriod.builder(accrual1).yearFraction(accrual1.yearFraction(ACT_365F, schedule)).rateComputation(IborAveragedRateComputation.of(fixings1)).build();

            IborIndexObservation obs4 = IborIndexObservation.of(GBP_LIBOR_3M, DATE_04_03, REF_DATA);
            IborIndexObservation obs5 = IborIndexObservation.of(GBP_LIBOR_3M, DATE_05_01, REF_DATA);
            IborIndexObservation obs6 = IborIndexObservation.of(GBP_LIBOR_3M, DATE_06_03, REF_DATA);
            ImmutableList <IborAveragedFixing> fixings2 = ImmutableList.of(IborAveragedFixing.ofDaysInResetPeriod(obs4, DATE_04_07, DATE_05_06), IborAveragedFixing.ofDaysInResetPeriod(obs5, DATE_05_06, DATE_06_05), IborAveragedFixing.ofDaysInResetPeriod(obs6, DATE_06_05, DATE_07_07));
            RateAccrualPeriod rap2 = RateAccrualPeriod.builder(accrual2).yearFraction(accrual2.yearFraction(ACT_365F, schedule)).rateComputation(IborAveragedRateComputation.of(fixings2)).build();
            ImmutableList <RateAccrualPeriod> periods = test.createAccrualPeriods(schedule, schedule, REF_DATA);

            assertEquals(periods, ImmutableList.of(rap1, rap2));
        }