public 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.getPayment(), PAYMENT_2014_10_03); assertEquals(test.getStartDate(), DATE_2014_03_30); assertEquals(test.getUnadjustedStartDate(), DATE_2014_03_30); assertEquals(test.getEndDate(), DATE_2014_09_30); assertEquals(test.getUnadjustedEndDate(), DATE_2014_09_30); assertEquals(test.getPaymentDate(), DATE_2014_10_03); assertEquals(test.getCurrency(), GBP); }
private List<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.getPaymentDateOffset().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.getPaymentRelativeTo().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 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.getStartDate().minusMonths(1)), Optional.empty()); // Date is on the start date assertEquals(test.findNotional(RPP1.getStartDate()), Optional.empty()); // Date is after the start date assertEquals(test.findNotional(RPP1.getStartDate().plusDays(1)), Optional.empty()); // Date is before the end date assertEquals(test.findNotional(RPP2.getEndDate().minusDays(1)), Optional.empty()); // Date is on the end date assertEquals(test.findNotional(RPP2.getEndDate()), Optional.empty()); // Date is after the end date assertEquals(test.findNotional(RPP2.getEndDate().plusMonths(1)), Optional.empty()); }