//-------------------------------------------------------------------------
        public virtual void test_collectIndices()
        {
            IborAveragedRateComputation test = IborAveragedRateComputation.of(FIXINGS);

            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(builder.build(), ImmutableSet.of(GBP_LIBOR_3M));
        }
Example #2
0
        //-------------------------------------------------------------------------
        public virtual void test_collectIndices()
        {
            IborRateComputation test = IborRateComputation.of(GBP_LIBOR_3M, date(2014, 6, 30), REF_DATA);

            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(builder.build(), ImmutableSet.of(GBP_LIBOR_3M));
        }
        //-------------------------------------------------------------------------
        public virtual void test_collectIndices_simple()
        {
            KnownAmountSwapPaymentPeriod test = 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();

            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(builder.build(), ImmutableSet.of());
        }
        //-------------------------------------------------------------------------
        public virtual void test_collectIndices()
        {
            InflationInterpolatedRateComputation test = InflationInterpolatedRateComputation.of(GB_HICP, START_MONTH_FIRST, END_MONTH_FIRST, WEIGHT);

            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(builder.build(), ImmutableSet.of(GB_HICP));
        }
        //-------------------------------------------------------------------------
        public virtual void test_collectIndices()
        {
            FixedRateCalculation test = FixedRateCalculation.builder().dayCount(ACT_365F).rate(ValueSchedule.of(0.025d)).build();

            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(builder.build(), ImmutableSet.of());
        }
Example #6
0
        public virtual void test_collectIndices_fxReset()
        {
            RatePaymentPeriod test = RatePaymentPeriod.builder().paymentDate(DATE_2014_10_01).accrualPeriods(RAP2).dayCount(ACT_365F).currency(GBP).notional(1000d).fxReset(FX_RESET_USD).compoundingMethod(CompoundingMethod.STRAIGHT).build();

            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(builder.build(), ImmutableSet.of(GBP_LIBOR_3M, GBP_USD_WM));
        }
        //-------------------------------------------------------------------------
        public virtual void test_collectIndices()
        {
            FixedRateComputation test = FixedRateComputation.of(0.05);

            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(builder.build(), ImmutableSet.of());
        }
        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));
        }
        //-------------------------------------------------------------------------
        public virtual void test_collectIndices()
        {
            OvernightRateCalculation test = OvernightRateCalculation.builder().dayCount(ACT_365F).index(GBP_SONIA).build();

            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(builder.build(), ImmutableSet.of(GBP_SONIA));
        }
        //-------------------------------------------------------------------------
        public virtual void test_collectIndices()
        {
            IborInterpolatedRateComputation test = IborInterpolatedRateComputation.of(GBP_LIBOR_1M, GBP_LIBOR_3M, FIXING_DATE, REF_DATA);

            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(builder.build(), ImmutableSet.of(GBP_LIBOR_1M, GBP_LIBOR_3M));
        }
        //-------------------------------------------------------------------------
        public virtual void test_collectIndices_simple()
        {
            IborRateCalculation test = IborRateCalculation.builder().dayCount(ACT_365F).index(GBP_LIBOR_1M).fixingDateOffset(MINUS_TWO_DAYS).build();

            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(builder.build(), ImmutableSet.of(GBP_LIBOR_1M));
        }
Example #12
0
        public virtual void test_collectIndices()
        {
            ResolvedSwapLeg test = ResolvedSwapLeg.builder().type(IBOR).payReceive(RECEIVE).paymentPeriods(RPP1).paymentEvents(NOTIONAL_EXCHANGE).build();

            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(builder.build(), ImmutableSet.of(GBP_LIBOR_3M));
        }
Example #13
0
        //-------------------------------------------------------------------------
        public virtual void test_collectIndices_simple()
        {
            KnownAmountRateComputation test = KnownAmountRateComputation.of(GBP_P1000);

            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(builder.build(), ImmutableSet.of());
        }
        //-------------------------------------------------------------------------
        public virtual void test_collectIndices()
        {
            OvernightCompoundedRateComputation test = OvernightCompoundedRateComputation.of(USD_FED_FUND, date(2016, 2, 24), date(2016, 3, 24), REF_DATA);

            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(builder.build(), ImmutableSet.of(USD_FED_FUND));
        }
Example #15
0
        //-------------------------------------------------------------------------
        public virtual void test_collectIndices()
        {
            InflationEndMonthRateComputation test = InflationEndMonthRateComputation.of(GB_HICP, START_INDEX, END_MONTH);

            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(builder.build(), ImmutableSet.of(GB_HICP));
        }
Example #16
0
        //-------------------------------------------------------------------------
        public virtual void test_collectIndices()
        {
            InflationRateCalculation test = InflationRateCalculation.builder().index(GB_HICP).lag(Period.ofMonths(3)).indexCalculationMethod(MONTHLY).build();

            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(builder.build(), ImmutableSet.of(GB_HICP));
        }
Example #17
0
        public virtual void test_collectIndices_fxReset()
        {
            SchedulePeriod sched = SchedulePeriod.of(DATE_2014_03_30, DATE_2014_09_30);
            KnownAmountNotionalSwapPaymentPeriod test = KnownAmountNotionalSwapPaymentPeriod.of(PAYMENT_2014_10_03, sched, USD_P50000, FX_RESET);

            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(builder.build(), ImmutableSet.of(FX_RESET.Index));
        }
        //-------------------------------------------------------------------------
        public virtual void test_collectIndices()
        {
            KnownAmountSwapLeg test = KnownAmountSwapLeg.builder().payReceive(PAY).accrualSchedule(PeriodicSchedule.builder().startDate(DATE_01_05).endDate(DATE_04_05).frequency(P1M).businessDayAdjustment(BusinessDayAdjustment.of(FOLLOWING, GBLO)).build()).paymentSchedule(PaymentSchedule.builder().paymentFrequency(P1M).paymentDateOffset(DaysAdjustment.ofBusinessDays(2, GBLO)).build()).amount(ValueSchedule.of(123d)).currency(GBP).build();

            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(builder.build(), ImmutableSet.of());
            assertEquals(test.allIndices(), ImmutableSet.of());
        }
        public virtual void test_collectIndices_fxReset()
        {
            RatePeriodSwapLeg test = RatePeriodSwapLeg.builder().type(IBOR).payReceive(RECEIVE).paymentPeriods(RPP1_FXRESET).build();

            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(builder.build(), ImmutableSet.of(GBP_LIBOR_3M, GBP_USD_WM));
            assertEquals(test.allCurrencies(), ImmutableSet.of(GBP, USD));
        }
        public virtual void test_collectIndices_fxReset()
        {
            RateCalculationSwapLeg test = RateCalculationSwapLeg.builder().payReceive(PAY).accrualSchedule(PeriodicSchedule.builder().startDate(DATE_01_05).endDate(DATE_04_05).frequency(P1M).businessDayAdjustment(BusinessDayAdjustment.of(FOLLOWING, GBLO)).build()).paymentSchedule(PaymentSchedule.builder().paymentFrequency(P1M).paymentDateOffset(PLUS_TWO_DAYS).build()).notionalSchedule(NotionalSchedule.builder().currency(GBP).amount(ValueSchedule.of(1000d)).finalExchange(true).fxReset(FxResetCalculation.builder().referenceCurrency(EUR).index(EUR_GBP_ECB).fixingDateOffset(MINUS_TWO_DAYS).build()).build()).calculation(IborRateCalculation.builder().dayCount(DayCounts.ACT_365F).index(GBP_LIBOR_3M).fixingDateOffset(MINUS_TWO_DAYS).build()).build();

            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(builder.build(), ImmutableSet.of(GBP_LIBOR_3M, EUR_GBP_ECB));
            assertEquals(test.allIndices(), ImmutableSet.of(GBP_LIBOR_3M, EUR_GBP_ECB));
            assertEquals(test.allCurrencies(), ImmutableSet.of(GBP, EUR));
        }
        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);
        }