//-------------------------------------------------------------------------
        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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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());
        }