//-------------------------------------------------------------------------
        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_adjustPaymentDate()
        {
            KnownAmountSwapPaymentPeriod test     = KnownAmountSwapPaymentPeriod.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).build();
            KnownAmountSwapPaymentPeriod expected = 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();

            assertEquals(test.adjustPaymentDate(TemporalAdjusters.ofDateAdjuster(d => d.plusDays(0))), test);
            assertEquals(test.adjustPaymentDate(TemporalAdjusters.ofDateAdjuster(d => d.plusDays(2))), expected);
        }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            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();

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

            coverBeanEquals(test, test2);
        }
        public virtual void test_builder_defaultDates()
        {
            KnownAmountSwapPaymentPeriod test = KnownAmountSwapPaymentPeriod.builder().payment(PAYMENT_2014_10_03).startDate(DATE_2014_03_30).endDate(DATE_2014_10_01).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);
        }
        //-------------------------------------------------------------------------
        public virtual void test_resolve()
        {
            // test case
            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(PLUS_TWO_DAYS).build()).amount(ValueSchedule.builder().initialValue(123d).steps(ValueStep.of(1, ValueAdjustment.ofReplace(234d))).build()).currency(GBP).build();
            // expected
            KnownAmountSwapPaymentPeriod rpp1 = KnownAmountSwapPaymentPeriod.builder().payment(Payment.ofPay(CurrencyAmount.of(GBP, 123d), DATE_02_07)).startDate(DATE_01_06).endDate(DATE_02_05).unadjustedStartDate(DATE_01_05).build();
            KnownAmountSwapPaymentPeriod rpp2 = KnownAmountSwapPaymentPeriod.builder().payment(Payment.ofPay(CurrencyAmount.of(GBP, 234d), DATE_03_07)).startDate(DATE_02_05).endDate(DATE_03_05).build();
            KnownAmountSwapPaymentPeriod rpp3 = KnownAmountSwapPaymentPeriod.builder().payment(Payment.ofPay(CurrencyAmount.of(GBP, 234d), DATE_04_09)).startDate(DATE_03_05).endDate(DATE_04_07).unadjustedEndDate(DATE_04_05).build();

            // assertion
            assertEquals(test.resolve(REF_DATA), ResolvedSwapLeg.builder().type(FIXED).payReceive(PAY).paymentPeriods(rpp1, rpp2, rpp3).build());
        }
        //-------------------------------------------------------------------------
        public virtual void test_of()
        {
            SchedulePeriod sched = SchedulePeriod.of(DATE_2014_03_30, DATE_2014_09_30);
            KnownAmountSwapPaymentPeriod test = KnownAmountSwapPaymentPeriod.of(PAYMENT_2014_10_03, sched);

            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);
        }
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         KnownAmountSwapPaymentPeriod other = (KnownAmountSwapPaymentPeriod)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));
     }
     return(false);
 }
Beispiel #8
0
        public virtual void test_findNotionalKnownAmount()
        {
            Payment        payment        = Payment.of(GBP, 1000, LocalDate.of(2011, 3, 8));
            SchedulePeriod schedulePeriod = SchedulePeriod.of(LocalDate.of(2010, 3, 8), LocalDate.of(2011, 3, 8));
            KnownAmountSwapPaymentPeriod paymentPeriod = KnownAmountSwapPaymentPeriod.of(payment, schedulePeriod);
            ResolvedSwapLeg test = ResolvedSwapLeg.builder().type(IBOR).payReceive(RECEIVE).paymentPeriods(paymentPeriod).build();

            // Date is before the start date
            assertEquals(test.findNotional(RPP1.StartDate.minusMonths(1)), null);
            // Date is on the start date
            assertEquals(test.findNotional(RPP1.StartDate), null);
            // Date is after the start date
            assertEquals(test.findNotional(RPP1.StartDate.plusDays(1)), null);
            // Date is before the end date
            assertEquals(test.findNotional(RPP2.EndDate.minusDays(1)), null);
            // Date is on the end date
            assertEquals(test.findNotional(RPP2.EndDate), null);
            // Date is after the end date
            assertEquals(test.findNotional(RPP2.EndDate.plusMonths(1)), null);
        }
Beispiel #9
0
        // create the payment period
        private IList <SwapPaymentPeriod> createPaymentPeriods(Schedule resolvedPayments, ReferenceData refData)
        {
            // resolve amount schedule against payment schedule
            DoubleArray amounts = amount.resolveValues(resolvedPayments);
            // resolve against reference data once
            DateAdjuster paymentDateAdjuster = paymentSchedule.PaymentDateOffset.resolve(refData);

            // build up payment periods using schedule
            ImmutableList.Builder <SwapPaymentPeriod> paymentPeriods = ImmutableList.builder();
            for (int index = 0; index < resolvedPayments.size(); index++)
            {
                SchedulePeriod paymentPeriod = resolvedPayments.getPeriod(index);
                LocalDate      baseDate      = paymentSchedule.PaymentRelativeTo.selectBaseDate(paymentPeriod);
                LocalDate      paymentDate   = paymentDateAdjuster.adjust(baseDate);
                double         amount        = payReceive.normalize(amounts.get(index));
                Payment        payment       = Payment.of(CurrencyAmount.of(currency, amount), paymentDate);
                paymentPeriods.add(KnownAmountSwapPaymentPeriod.of(payment, paymentPeriod));
            }
            return(paymentPeriods.build());
        }
 public virtual void test_builder_invalid()
 {
     assertThrowsIllegalArg(() => KnownAmountSwapPaymentPeriod.builder().payment(PAYMENT_2014_10_03).endDate(DATE_2014_10_01).build());
     assertThrowsIllegalArg(() => KnownAmountSwapPaymentPeriod.builder().payment(PAYMENT_2014_10_03).startDate(DATE_2014_10_01).build());
     assertThrowsIllegalArg(() => KnownAmountSwapPaymentPeriod.builder().payment(PAYMENT_2014_10_03).startDate(DATE_2014_10_01).endDate(DATE_2014_10_01).build());
 }
        public virtual void test_serialization()
        {
            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();

            assertSerialization(test);
        }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance based on a payment and schedule period.
 /// </summary>
 /// <param name="payment">  the payment </param>
 /// <param name="period">  the schedule period </param>
 /// <returns> the period </returns>
 public static KnownAmountSwapPaymentPeriod of(Payment payment, SchedulePeriod period)
 {
     return(KnownAmountSwapPaymentPeriod.builder().payment(payment).startDate(period.StartDate).endDate(period.EndDate).unadjustedStartDate(period.UnadjustedStartDate).unadjustedEndDate(period.UnadjustedEndDate).build());
 }