//-------------------------------------------------------------------------
        public virtual void coverage()
        {
            NotionalSchedule test = NotionalSchedule.of(GBP, 1000d);

            coverImmutableBean(test);
            NotionalSchedule test2 = NotionalSchedule.builder().currency(USD).amount(ValueSchedule.of(2000d)).fxReset(FxResetCalculation.builder().referenceCurrency(GBP).index(GBP_USD_WM).fixingDateOffset(DaysAdjustment.ofBusinessDays(-2, GBLO)).build()).initialExchange(true).intermediateExchange(true).finalExchange(true).build();

            coverBeanEquals(test, test2);
        }
        public virtual void test_builder_FxResetSetsFlags()
        {
            FxResetCalculation fxReset = FxResetCalculation.builder().referenceCurrency(GBP).index(GBP_USD_WM).fixingDateOffset(DaysAdjustment.ofBusinessDays(-2, GBLO)).build();
            NotionalSchedule   test    = NotionalSchedule.builder().currency(USD).amount(ValueSchedule.of(2000d)).intermediateExchange(true).finalExchange(true).fxReset(fxReset).build();

            assertEquals(test.Currency, USD);
            assertEquals(test.Amount, ValueSchedule.of(2000d));
            assertEquals(test.FxReset, fxReset);
            assertEquals(test.InitialExchange, false);
            assertEquals(test.IntermediateExchange, true);
            assertEquals(test.FinalExchange, true);
        }
 public virtual void test_builder_invalidCurrencyFxReset()
 {
     assertThrowsIllegalArg(() => NotionalSchedule.builder().currency(USD).amount(ValueSchedule.of(2000d)).fxReset(FxResetCalculation.builder().referenceCurrency(USD).index(GBP_USD_WM).fixingDateOffset(DaysAdjustment.ofBusinessDays(-2, GBLO)).build()).build());
     assertThrowsIllegalArg(() => NotionalSchedule.builder().currency(EUR).amount(ValueSchedule.of(2000d)).fxReset(FxResetCalculation.builder().referenceCurrency(USD).index(GBP_USD_WM).fixingDateOffset(DaysAdjustment.ofBusinessDays(-2, GBLO)).build()).build());
 }
예제 #4
0
 /// <summary>
 /// Obtains an instance with a notional amount that can change over time.
 /// </summary>
 /// <param name="currency">  the currency of the notional and swap payments </param>
 /// <param name="amountSchedule">  the schedule describing how the notional changes over time </param>
 /// <returns> the notional amount </returns>
 public static NotionalSchedule of(Currency currency, ValueSchedule amountSchedule)
 {
     ArgChecker.notNull(currency, "currency");
     ArgChecker.notNull(amountSchedule, "amountSchedule");
     return(NotionalSchedule.builder().currency(currency).amount(amountSchedule).build());
 }
예제 #5
0
 /// <summary>
 /// Obtains an instance with a single amount that does not change over time.
 /// </summary>
 /// <param name="currency">  the currency of the notional and swap payments </param>
 /// <param name="amount">  the single notional amount that does not change over time </param>
 /// <returns> the notional amount </returns>
 public static NotionalSchedule of(Currency currency, double amount)
 {
     ArgChecker.notNull(currency, "currency");
     return(NotionalSchedule.builder().currency(currency).amount(ValueSchedule.of(amount)).build());
 }
예제 #6
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance with a single amount that does not change over time.
 /// </summary>
 /// <param name="notional">  the single notional that does not change over time </param>
 /// <returns> the notional amount </returns>
 public static NotionalSchedule of(CurrencyAmount notional)
 {
     ArgChecker.notNull(notional, "notional");
     return(NotionalSchedule.builder().currency(notional.Currency).amount(ValueSchedule.of(notional.Amount)).build());
 }
        //-------------------------------------------------------------------------
        public virtual void test_resolve_oneAccrualPerPayment_fxReset()
        {
            // test case
            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)).fxReset(FxResetCalculation.builder().referenceCurrency(EUR).index(EUR_GBP_ECB).fixingDateOffset(MINUS_TWO_DAYS).build()).initialExchange(true).intermediateExchange(true).finalExchange(true).build()).calculation(FixedRateCalculation.builder().dayCount(ACT_365F).rate(ValueSchedule.of(0.025d)).build()).build();
            // expected
            RatePaymentPeriod       rpp1 = RatePaymentPeriod.builder().paymentDate(DATE_02_07).accrualPeriods(RateAccrualPeriod.builder().startDate(DATE_01_06).endDate(DATE_02_05).unadjustedStartDate(DATE_01_05).yearFraction(ACT_365F.yearFraction(DATE_01_06, DATE_02_05)).rateComputation(FixedRateComputation.of(0.025d)).build()).dayCount(ACT_365F).currency(GBP).notional(-1000d).fxReset(FxReset.of(FxIndexObservation.of(EUR_GBP_ECB, DATE_01_02, REF_DATA), EUR)).build();
            RatePaymentPeriod       rpp2 = RatePaymentPeriod.builder().paymentDate(DATE_03_07).accrualPeriods(RateAccrualPeriod.builder().startDate(DATE_02_05).endDate(DATE_03_05).yearFraction(ACT_365F.yearFraction(DATE_02_05, DATE_03_05)).rateComputation(FixedRateComputation.of(0.025d)).build()).dayCount(ACT_365F).currency(GBP).notional(-1000d).fxReset(FxReset.of(FxIndexObservation.of(EUR_GBP_ECB, DATE_02_03, REF_DATA), EUR)).build();
            RatePaymentPeriod       rpp3 = RatePaymentPeriod.builder().paymentDate(DATE_04_09).accrualPeriods(RateAccrualPeriod.builder().startDate(DATE_03_05).endDate(DATE_04_07).unadjustedEndDate(DATE_04_05).yearFraction(ACT_365F.yearFraction(DATE_03_05, DATE_04_07)).rateComputation(FixedRateComputation.of(0.025d)).build()).dayCount(ACT_365F).currency(GBP).notional(-1000d).fxReset(FxReset.of(FxIndexObservation.of(EUR_GBP_ECB, DATE_03_03, REF_DATA), EUR)).build();
            FxResetNotionalExchange ne1a = FxResetNotionalExchange.of(CurrencyAmount.of(EUR, 1000d), DATE_01_06, FxIndexObservation.of(EUR_GBP_ECB, DATE_01_02, REF_DATA));
            FxResetNotionalExchange ne1b = FxResetNotionalExchange.of(CurrencyAmount.of(EUR, -1000d), DATE_02_07, FxIndexObservation.of(EUR_GBP_ECB, DATE_01_02, REF_DATA));
            FxResetNotionalExchange ne2a = FxResetNotionalExchange.of(CurrencyAmount.of(EUR, 1000d), DATE_02_07, FxIndexObservation.of(EUR_GBP_ECB, DATE_02_03, REF_DATA));
            FxResetNotionalExchange ne2b = FxResetNotionalExchange.of(CurrencyAmount.of(EUR, -1000d), DATE_03_07, FxIndexObservation.of(EUR_GBP_ECB, DATE_02_03, REF_DATA));
            FxResetNotionalExchange ne3a = FxResetNotionalExchange.of(CurrencyAmount.of(EUR, 1000d), DATE_03_07, FxIndexObservation.of(EUR_GBP_ECB, DATE_03_03, REF_DATA));
            FxResetNotionalExchange ne3b = FxResetNotionalExchange.of(CurrencyAmount.of(EUR, -1000d), DATE_04_09, FxIndexObservation.of(EUR_GBP_ECB, DATE_03_03, REF_DATA));

            // assertion
            assertEquals(test.resolve(REF_DATA), ResolvedSwapLeg.builder().type(FIXED).payReceive(PAY).paymentPeriods(rpp1, rpp2, rpp3).paymentEvents(ne1a, ne1b, ne2a, ne2b, ne3a, ne3b).build());
        }
        public virtual void test_resolve_twoAccrualsPerPayment_iborRate_varyingNotional_notionalExchange()
        {
            // test case
            RateCalculationSwapLeg test = RateCalculationSwapLeg.builder().payReceive(PAY).accrualSchedule(PeriodicSchedule.builder().startDate(DATE_01_05).endDate(DATE_06_05).frequency(P1M).businessDayAdjustment(BusinessDayAdjustment.of(FOLLOWING, GBLO)).build()).paymentSchedule(PaymentSchedule.builder().paymentFrequency(P2M).paymentDateOffset(PLUS_TWO_DAYS).compoundingMethod(STRAIGHT).build()).notionalSchedule(NotionalSchedule.builder().currency(GBP).amount(ValueSchedule.of(1000d, ValueStep.of(1, ValueAdjustment.ofReplace(1500d)))).initialExchange(true).intermediateExchange(true).finalExchange(true).build()).calculation(IborRateCalculation.builder().dayCount(ACT_365F).index(GBP_LIBOR_1M).fixingDateOffset(DaysAdjustment.ofBusinessDays(-2, GBLO)).build()).build();
            // expected
            RatePaymentPeriod rpp1 = RatePaymentPeriod.builder().paymentDate(DATE_03_07).accrualPeriods(RateAccrualPeriod.builder().startDate(DATE_01_06).endDate(DATE_02_05).unadjustedStartDate(DATE_01_05).yearFraction(ACT_365F.yearFraction(DATE_01_06, DATE_02_05)).rateComputation(IborRateComputation.of(GBP_LIBOR_1M, DATE_01_02, REF_DATA)).build(), RateAccrualPeriod.builder().startDate(DATE_02_05).endDate(DATE_03_05).yearFraction(ACT_365F.yearFraction(DATE_02_05, DATE_03_05)).rateComputation(IborRateComputation.of(GBP_LIBOR_1M, DATE_02_03, REF_DATA)).build()).dayCount(ACT_365F).currency(GBP).notional(-1000d).compoundingMethod(STRAIGHT).build();
            RatePaymentPeriod rpp2 = RatePaymentPeriod.builder().paymentDate(DATE_05_08).accrualPeriods(RateAccrualPeriod.builder().startDate(DATE_03_05).endDate(DATE_04_07).unadjustedEndDate(DATE_04_05).yearFraction(ACT_365F.yearFraction(DATE_03_05, DATE_04_07)).rateComputation(IborRateComputation.of(GBP_LIBOR_1M, DATE_03_03, REF_DATA)).build(), RateAccrualPeriod.builder().startDate(DATE_04_07).endDate(DATE_05_06).unadjustedStartDate(DATE_04_05).unadjustedEndDate(DATE_05_05).yearFraction(ACT_365F.yearFraction(DATE_04_07, DATE_05_06)).rateComputation(IborRateComputation.of(GBP_LIBOR_1M, DATE_04_03, REF_DATA)).build()).dayCount(ACT_365F).currency(GBP).notional(-1500d).compoundingMethod(STRAIGHT).build();
            RatePaymentPeriod rpp3 = RatePaymentPeriod.builder().paymentDate(DATE_06_09).accrualPeriods(RateAccrualPeriod.builder().startDate(DATE_05_06).endDate(DATE_06_05).unadjustedStartDate(DATE_05_05).yearFraction(ACT_365F.yearFraction(DATE_05_06, DATE_06_05)).rateComputation(IborRateComputation.of(GBP_LIBOR_1M, DATE_05_01, REF_DATA)).build()).dayCount(ACT_365F).currency(GBP).notional(-1500d).compoundingMethod(STRAIGHT).build();
            // events (only one intermediate exchange)
            NotionalExchange nexInitial      = NotionalExchange.of(CurrencyAmount.of(GBP, 1000d), DATE_01_06);
            NotionalExchange nexIntermediate = NotionalExchange.of(CurrencyAmount.of(GBP, 500d), DATE_03_07);
            NotionalExchange nexFinal        = NotionalExchange.of(CurrencyAmount.of(GBP, -1500d), DATE_06_09);

            // assertion
            assertEquals(test.resolve(REF_DATA), ResolvedSwapLeg.builder().type(IBOR).payReceive(PAY).paymentPeriods(rpp1, rpp2, rpp3).paymentEvents(nexInitial, nexIntermediate, nexFinal).build());
        }
        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));
        }