public virtual void test_of_null()
 {
     assertThrowsIllegalArg(() => IborRateStubCalculation.ofIborRate(null));
     assertThrowsIllegalArg(() => IborRateStubCalculation.ofIborInterpolatedRate(null, GBP_LIBOR_3M));
     assertThrowsIllegalArg(() => IborRateStubCalculation.ofIborInterpolatedRate(GBP_LIBOR_3M, null));
     assertThrowsIllegalArg(() => IborRateStubCalculation.ofIborInterpolatedRate(null, null));
 }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            IborRateStubCalculation test = IborRateStubCalculation.ofIborInterpolatedRate(GBP_LIBOR_1M, GBP_LIBOR_3M);

            coverImmutableBean(test);
            IborRateStubCalculation test2 = IborRateStubCalculation.ofFixedRate(0.028d);

            coverBeanEquals(test, test2);
            IborRateStubCalculation test3 = IborRateStubCalculation.ofKnownAmount(GBP_P1000);

            coverBeanEquals(test, test3);
        }
        public virtual void test_ofIborInterpolatedRate()
        {
            IborRateStubCalculation test = IborRateStubCalculation.ofIborInterpolatedRate(GBP_LIBOR_1M, GBP_LIBOR_3M);

            assertEquals(test.FixedRate, double?.empty());
            assertEquals(test.Index, GBP_LIBOR_1M);
            assertEquals(test.IndexInterpolated, GBP_LIBOR_3M);
            assertEquals(test.FixedRate, false);
            assertEquals(test.KnownAmount, false);
            assertEquals(test.FloatingRate, true);
            assertEquals(test.Interpolated, true);
        }
        //-------------------------------------------------------------------------
        public virtual void test_ofFixedRate()
        {
            IborRateStubCalculation test = IborRateStubCalculation.ofFixedRate(0.025d);

            assertEquals(test.FixedRate, double?.of(0.025d));
            assertEquals(test.Index, null);
            assertEquals(test.IndexInterpolated, null);
            assertEquals(test.FixedRate, true);
            assertEquals(test.KnownAmount, false);
            assertEquals(test.FloatingRate, false);
            assertEquals(test.Interpolated, false);
        }
Пример #5
0
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         IborRateStubCalculation other = (IborRateStubCalculation)obj;
         return(JodaBeanUtils.equal(fixedRate, other.fixedRate) && JodaBeanUtils.equal(knownAmount, other.knownAmount) && JodaBeanUtils.equal(index, other.index) && JodaBeanUtils.equal(indexInterpolated, other.indexInterpolated));
     }
     return(false);
 }
        public virtual void test_ofKnownAmount()
        {
            IborRateStubCalculation test = IborRateStubCalculation.ofKnownAmount(GBP_P1000);

            assertEquals(test.FixedRate, double?.empty());
            assertEquals(test.KnownAmount, GBP_P1000);
            assertEquals(test.Index, null);
            assertEquals(test.IndexInterpolated, null);
            assertEquals(test.FixedRate, false);
            assertEquals(test.KnownAmount, true);
            assertEquals(test.FloatingRate, false);
            assertEquals(test.Interpolated, false);
        }
        public virtual void test_serialization()
        {
            IborRateStubCalculation test = IborRateStubCalculation.ofIborRate(GBP_LIBOR_3M);

            assertSerialization(test);
        }
        public virtual void test_createRateComputation_knownAmount()
        {
            IborRateStubCalculation test = IborRateStubCalculation.ofKnownAmount(GBP_P1000);

            assertEquals(test.createRateComputation(DATE, GBP_LIBOR_3M, REF_DATA), KnownAmountRateComputation.of(GBP_P1000));
        }
        public virtual void test_createRateComputation_fixedRate()
        {
            IborRateStubCalculation test = IborRateStubCalculation.ofFixedRate(0.025d);

            assertEquals(test.createRateComputation(DATE, GBP_LIBOR_3M, REF_DATA), FixedRateComputation.of(0.025d));
        }
        //-------------------------------------------------------------------------
        public virtual void test_createRateComputation_NONE()
        {
            IborRateStubCalculation test = IborRateStubCalculation.NONE;

            assertEquals(test.createRateComputation(DATE, GBP_LIBOR_3M, REF_DATA), IborRateComputation.of(GBP_LIBOR_3M, DATE, REF_DATA));
        }
        public virtual void test_expand_singlePeriod_stubCalcsInitialStub_interpolated()
        {
            IborRateCalculation test = IborRateCalculation.builder().dayCount(ACT_365F).index(GBP_LIBOR_2M).fixingDateOffset(MINUS_TWO_DAYS).initialStub(IborRateStubCalculation.ofIborInterpolatedRate(GBP_LIBOR_1W, GBP_LIBOR_1M)).build();
            RateAccrualPeriod   rap1 = RateAccrualPeriod.builder(ACCRUAL1STUB).yearFraction(ACCRUAL1STUB.yearFraction(ACT_365F, ACCRUAL_SCHEDULE_STUBS)).rateComputation(IborInterpolatedRateComputation.of(GBP_LIBOR_1W, GBP_LIBOR_1M, DATE_01_06, REF_DATA)).build();
            ImmutableList <RateAccrualPeriod> periods = test.createAccrualPeriods(SINGLE_ACCRUAL_SCHEDULE_STUB, SINGLE_ACCRUAL_SCHEDULE_STUB, REF_DATA);

            assertEquals(periods, ImmutableList.of(rap1));
        }
 public virtual void test_builder_invalid_fixedAndKnown()
 {
     assertThrowsIllegalArg(() => IborRateStubCalculation.builder().fixedRate(0.025d).knownAmount(GBP_P1000).build());
 }
 //-------------------------------------------------------------------------
 public virtual void test_builder_invalid_fixedAndIbor()
 {
     assertThrowsIllegalArg(() => IborRateStubCalculation.builder().fixedRate(0.025d).index(GBP_LIBOR_3M).build());
 }
        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_firstRateFixedInitialStubSpecified()
        {
            IborRateCalculation test = IborRateCalculation.builder().dayCount(ACT_365F).index(GBP_LIBOR_1M).fixingDateOffset(MINUS_TWO_DAYS).initialStub(IborRateStubCalculation.ofIborRate(GBP_LIBOR_1W)).firstRate(0.024d).build();
            RateAccrualPeriod   rap1 = RateAccrualPeriod.builder(ACCRUAL1STUB).yearFraction(ACCRUAL1STUB.yearFraction(ACT_365F, ACCRUAL_SCHEDULE_INITIAL_STUB)).rateComputation(IborRateComputation.of(GBP_LIBOR_1W, DATE_01_06, REF_DATA)).build();
            RateAccrualPeriod   rap2 = RateAccrualPeriod.builder(ACCRUAL2).yearFraction(ACCRUAL2.yearFraction(ACT_365F, ACCRUAL_SCHEDULE_INITIAL_STUB)).rateComputation(IborRateComputation.of(GBP_LIBOR_1M, DATE_02_03, REF_DATA)).build();
            RateAccrualPeriod   rap3 = RateAccrualPeriod.builder(ACCRUAL3).yearFraction(ACCRUAL3.yearFraction(ACT_365F, ACCRUAL_SCHEDULE_INITIAL_STUB)).rateComputation(IborRateComputation.of(GBP_LIBOR_1M, DATE_03_03, REF_DATA)).build();
            ImmutableList <RateAccrualPeriod> periods = test.createAccrualPeriods(ACCRUAL_SCHEDULE_INITIAL_STUB, ACCRUAL_SCHEDULE_INITIAL_STUB, REF_DATA);

            assertEquals(periods, ImmutableList.of(rap1, rap2, rap3));
        }
 public virtual void test_builder_invalid_knownAndIbor()
 {
     assertThrowsIllegalArg(() => IborRateStubCalculation.builder().knownAmount(GBP_P1000).index(GBP_LIBOR_3M).build());
 }
 public virtual void test_builder_invalid_interpolatedSameIndex()
 {
     assertThrowsIllegalArg(() => IborRateStubCalculation.builder().index(GBP_LIBOR_3M).indexInterpolated(GBP_LIBOR_3M).build());
 }
 public virtual void test_ofIborInterpolatedRate_invalid_interpolatedSameIndex()
 {
     assertThrowsIllegalArg(() => IborRateStubCalculation.ofIborInterpolatedRate(GBP_LIBOR_3M, GBP_LIBOR_3M));
 }
        public virtual void test_collectIndices_stubCalcsTwoStubs_interpolated()
        {
            IborRateCalculation test = IborRateCalculation.builder().dayCount(ACT_365F).index(GBP_LIBOR_1M).fixingDateOffset(MINUS_TWO_DAYS).initialStub(IborRateStubCalculation.ofIborInterpolatedRate(GBP_LIBOR_1W, GBP_LIBOR_1M)).finalStub(IborRateStubCalculation.ofIborInterpolatedRate(GBP_LIBOR_3M, GBP_LIBOR_1M)).build();

            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(builder.build(), ImmutableSet.of(GBP_LIBOR_1M, GBP_LIBOR_1W, GBP_LIBOR_3M));
        }