Ejemplo n.º 1
0
        //-------------------------------------------------------------------------
        public virtual void test_collectIndices_simple()
        {
            KnownAmountNotionalSwapPaymentPeriod test = KnownAmountNotionalSwapPaymentPeriod.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).notionalAmount(GBP_P50000).build();

            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(builder.build(), ImmutableSet.of());
        }
Ejemplo n.º 2
0
        //-------------------------------------------------------------------------
        public virtual void test_adjustPaymentDate()
        {
            KnownAmountNotionalSwapPaymentPeriod test     = KnownAmountNotionalSwapPaymentPeriod.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).notionalAmount(GBP_P50000).build();
            KnownAmountNotionalSwapPaymentPeriod expected = KnownAmountNotionalSwapPaymentPeriod.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).notionalAmount(GBP_P50000).build();

            assertEquals(test.adjustPaymentDate(TemporalAdjusters.ofDateAdjuster(d => d.plusDays(0))), test);
            assertEquals(test.adjustPaymentDate(TemporalAdjusters.ofDateAdjuster(d => d.plusDays(2))), expected);
        }
Ejemplo n.º 3
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            KnownAmountNotionalSwapPaymentPeriod test = KnownAmountNotionalSwapPaymentPeriod.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).notionalAmount(GBP_P50000).build();

            coverImmutableBean(test);
            KnownAmountNotionalSwapPaymentPeriod test2 = KnownAmountNotionalSwapPaymentPeriod.builder().payment(PAYMENT_2014_10_03.negated()).startDate(DATE_2014_06_30).endDate(DATE_2014_09_30).notionalAmount(GBP_P1000).build();

            coverBeanEquals(test, test2);
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
0
 public virtual void test_builder_invalid()
 {
     assertThrowsIllegalArg(() => KnownAmountNotionalSwapPaymentPeriod.builder().payment(PAYMENT_2014_10_03).endDate(DATE_2014_10_01).notionalAmount(GBP_P50000).build());
     assertThrowsIllegalArg(() => KnownAmountNotionalSwapPaymentPeriod.builder().payment(PAYMENT_2014_10_03).startDate(DATE_2014_10_01).notionalAmount(GBP_P50000).build());
     assertThrowsIllegalArg(() => KnownAmountNotionalSwapPaymentPeriod.builder().payment(PAYMENT_2014_10_03).startDate(DATE_2014_10_01).endDate(DATE_2014_10_01).notionalAmount(GBP_P50000).build());
     assertThrowsIllegalArg(() => KnownAmountNotionalSwapPaymentPeriod.builder().payment(PAYMENT_2014_10_03).startDate(DATE_2014_03_30).endDate(DATE_2014_10_01).notionalAmount(CurrencyAmount.of(USD, 1000d)).build());
     assertThrowsIllegalArg(() => KnownAmountNotionalSwapPaymentPeriod.builder().payment(PAYMENT_2014_10_03).startDate(DATE_2014_03_30).endDate(DATE_2014_10_01).notionalAmount(CurrencyAmount.of(GBP, 1000d)).fxResetObservation(FX_RESET).build());
     assertThrowsIllegalArg(() => KnownAmountNotionalSwapPaymentPeriod.builder().payment(PAYMENT_2014_10_03).startDate(DATE_2014_03_30).endDate(DATE_2014_10_01).notionalAmount(CurrencyAmount.of(EUR, 1000d)).fxResetObservation(FX_RESET).build());
     assertThrowsIllegalArg(() => KnownAmountNotionalSwapPaymentPeriod.builder().payment(Payment.of(CurrencyAmount.of(EUR, 1000d), DATE_2014_10_03)).startDate(DATE_2014_03_30).endDate(DATE_2014_10_01).notionalAmount(CurrencyAmount.of(USD, 1000d)).fxResetObservation(FX_RESET).build());
 }
Ejemplo n.º 6
0
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         KnownAmountNotionalSwapPaymentPeriod other = (KnownAmountNotionalSwapPaymentPeriod)obj;
         return(JodaBeanUtils.equal(payment, other.payment) && JodaBeanUtils.equal(startDate, other.startDate) && JodaBeanUtils.equal(endDate, other.endDate) && JodaBeanUtils.equal(unadjustedStartDate, other.unadjustedStartDate) && JodaBeanUtils.equal(unadjustedEndDate, other.unadjustedEndDate) && JodaBeanUtils.equal(notionalAmount, other.notionalAmount) && JodaBeanUtils.equal(fxResetObservation, other.fxResetObservation));
     }
     return(false);
 }
        public virtual void test_resolve_knownAmountStub()
        {
            // test case
            CurrencyAmount         knownAmount = CurrencyAmount.of(GBP, 150d);
            RateCalculationSwapLeg test        = RateCalculationSwapLeg.builder().payReceive(PAY).accrualSchedule(PeriodicSchedule.builder().startDate(DATE_02_03).endDate(DATE_04_03).firstRegularStartDate(DATE_02_05).lastRegularEndDate(DATE_03_05).frequency(P1M).stubConvention(StubConvention.BOTH).businessDayAdjustment(BusinessDayAdjustment.of(FOLLOWING, GBLO)).build()).paymentSchedule(PaymentSchedule.builder().paymentFrequency(P1M).paymentDateOffset(PLUS_TWO_DAYS).build()).notionalSchedule(NotionalSchedule.of(GBP, 1000d)).calculation(FixedRateCalculation.builder().dayCount(ACT_365F).rate(ValueSchedule.of(0.025d)).initialStub(FixedRateStubCalculation.ofKnownAmount(knownAmount)).finalStub(FixedRateStubCalculation.ofFixedRate(0.1d)).build()).build();
            // expected
            KnownAmountNotionalSwapPaymentPeriod pp1 = KnownAmountNotionalSwapPaymentPeriod.builder().payment(Payment.of(knownAmount, DATE_02_07)).startDate(DATE_02_03).endDate(DATE_02_05).unadjustedStartDate(DATE_02_03).notionalAmount(CurrencyAmount.of(GBP, -1000d)).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).build();
            RatePaymentPeriod rpp3 = RatePaymentPeriod.builder().paymentDate(DATE_04_07).accrualPeriods(RateAccrualPeriod.builder().startDate(DATE_03_05).endDate(DATE_04_03).unadjustedEndDate(DATE_04_03).yearFraction(ACT_365F.yearFraction(DATE_03_05, DATE_04_03)).rateComputation(FixedRateComputation.of(0.1d)).build()).dayCount(ACT_365F).currency(GBP).notional(-1000d).build();

            // assertion
            assertEquals(test.resolve(REF_DATA), ResolvedSwapLeg.builder().type(FIXED).payReceive(PAY).paymentPeriods(pp1, rpp2, rpp3).build());
        }
Ejemplo n.º 8
0
        public virtual void test_builder_defaultDates()
        {
            KnownAmountNotionalSwapPaymentPeriod test = KnownAmountNotionalSwapPaymentPeriod.builder().payment(PAYMENT_2014_10_03).startDate(DATE_2014_03_30).endDate(DATE_2014_10_01).notionalAmount(USD_P50000).fxResetObservation(FX_RESET).build();

            assertEquals(test.Payment, PAYMENT_2014_10_03);
            assertEquals(test.StartDate, DATE_2014_03_30);
            assertEquals(test.UnadjustedStartDate, DATE_2014_03_30);
            assertEquals(test.EndDate, DATE_2014_10_01);
            assertEquals(test.UnadjustedEndDate, DATE_2014_10_01);
            assertEquals(test.PaymentDate, DATE_2014_10_03);
            assertEquals(test.Currency, GBP);
            assertEquals(test.NotionalAmount, USD_P50000);
            assertEquals(test.FxResetObservation, FX_RESET);
        }
Ejemplo n.º 9
0
        public virtual void test_of_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);

            assertEquals(test.Payment, PAYMENT_2014_10_03);
            assertEquals(test.StartDate, DATE_2014_03_30);
            assertEquals(test.UnadjustedStartDate, DATE_2014_03_30);
            assertEquals(test.EndDate, DATE_2014_09_30);
            assertEquals(test.UnadjustedEndDate, DATE_2014_09_30);
            assertEquals(test.PaymentDate, DATE_2014_10_03);
            assertEquals(test.Currency, GBP);
            assertEquals(test.NotionalAmount, USD_P50000);
            assertEquals(test.FxResetObservation, FX_RESET);
        }
Ejemplo n.º 10
0
        public virtual void test_serialization()
        {
            KnownAmountNotionalSwapPaymentPeriod test = KnownAmountNotionalSwapPaymentPeriod.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).notionalAmount(GBP_P50000).build();

            assertSerialization(test);
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Obtains an instance based on a payment, schedule period, notional and FX reset.
 /// </summary>
 /// <param name="payment">  the payment </param>
 /// <param name="period">  the schedule period </param>
 /// <param name="notional">  the notional </param>
 /// <param name="fxResetObservation">  the FX reset observation </param>
 /// <returns> the period </returns>
 public static KnownAmountNotionalSwapPaymentPeriod of(Payment payment, SchedulePeriod period, CurrencyAmount notional, FxIndexObservation fxResetObservation)
 {
     return(KnownAmountNotionalSwapPaymentPeriod.builder().payment(payment).startDate(period.StartDate).endDate(period.EndDate).unadjustedStartDate(period.UnadjustedStartDate).unadjustedEndDate(period.UnadjustedEndDate).notionalAmount(notional).fxResetObservation(fxResetObservation).build());
 }