@Override public NotionalExchange adjustPaymentDate(TemporalAdjuster adjuster) { LocalDate adjusted = payment.getDate().with(adjuster); return of(payment.getValue(), adjusted); }
public void test_serialization() { NotionalExchange test = NotionalExchange.of(GBP_1000, DATE_2014_06_30); assertSerialization(test); }
private static ImmutableList<SwapPaymentEvent> createStandardEvents( List<NotionalPaymentPeriod> payPeriods, LocalDate initialExchangePaymentDate, boolean initialExchange, boolean intermediateExchange, boolean finalExchange) { NotionalPaymentPeriod firstPeriod = payPeriods.get(0); ImmutableList.Builder<SwapPaymentEvent> events = ImmutableList.builder(); if (initialExchange) { events.add(NotionalExchange.of(firstPeriod.getNotionalAmount().negated(), initialExchangePaymentDate)); } if (intermediateExchange) { for (int i = 0; i < payPeriods.size() - 1; i++) { NotionalPaymentPeriod period1 = payPeriods.get(i); NotionalPaymentPeriod period2 = payPeriods.get(i + 1); if (period1.getNotionalAmount().getAmount() != period2.getNotionalAmount().getAmount()) { events.add(NotionalExchange.of( period1.getNotionalAmount().minus(period2.getNotionalAmount()), period1.getPaymentDate())); } } } if (finalExchange) { NotionalPaymentPeriod lastPeriod = payPeriods.get(payPeriods.size() - 1); events.add(NotionalExchange.of(lastPeriod.getNotionalAmount(), lastPeriod.getPaymentDate())); } return events.build(); }
public void test_of() { NotionalExchange test = NotionalExchange.of(GBP_1000, DATE_2014_06_30); assertEquals(test.getPayment(), Payment.of(GBP_1000, DATE_2014_06_30)); assertEquals(test.getPaymentDate(), DATE_2014_06_30); assertEquals(test.getPaymentAmount(), GBP_1000); assertEquals(test.getCurrency(), GBP); }
public void test_of_Payment() { NotionalExchange test = NotionalExchange.of(Payment.of(GBP_1000, DATE_2014_06_30)); assertEquals(test.getPayment(), Payment.of(GBP_1000, DATE_2014_06_30)); assertEquals(test.getPaymentDate(), DATE_2014_06_30); assertEquals(test.getPaymentAmount(), GBP_1000); assertEquals(test.getCurrency(), GBP); }
public void test_adjustPaymentDate() { NotionalExchange test = NotionalExchange.of(GBP_1000, DATE_2014_06_30); NotionalExchange expected = NotionalExchange.of(GBP_1000, DATE_2014_06_30.plusDays(2)); assertEquals(test.adjustPaymentDate(TemporalAdjusters.ofDateAdjuster(d -> d.plusDays(0))), test); assertEquals(test.adjustPaymentDate(TemporalAdjusters.ofDateAdjuster(d -> d.plusDays(2))), expected); }
CurrencyAmount notional = ratePaymentPeriod.getNotionalAmount().multipliedBy(factor); LocalDate paymentDate = ratePaymentPeriod.getPaymentDate(); NotionalExchange pay = NotionalExchange.of(notional, paymentDate); paymentEvents.add(pay);
ratesProvider.discountFactor(paymentPeriod.getCurrency(), fixingStartDate); double ycRatio = rateAccrualPeriod.getYearFraction() / fixingYearFraction; NotionalExchange payStart = NotionalExchange.of(notional.multipliedBy(beta * ycRatio), fixingStartDate); NotionalExchange payEnd = NotionalExchange.of(notional.multipliedBy(-ycRatio), paymentDate); paymentEvents.add(payStart); paymentEvents.add(payEnd);
public void test_resolve_createNotionalExchange() { RatePeriodSwapLeg test = RatePeriodSwapLeg.builder() .type(IBOR) .payReceive(RECEIVE) .paymentPeriods(RPP1) .initialExchange(true) .intermediateExchange(true) .finalExchange(true) .build(); ResolvedSwapLeg expected = ResolvedSwapLeg.builder() .type(IBOR) .payReceive(RECEIVE) .paymentPeriods(RPP1) .paymentEvents( NotionalExchange.of(CurrencyAmount.of(GBP, -5000d), DATE_2014_06_30), NotionalExchange.of(CurrencyAmount.of(GBP, 5000d), DATE_2014_10_01)) .build(); assertEquals(test.resolve(REF_DATA), expected); }
NotionalExchange fixedPayment1 = NotionalExchange.of(CurrencyAmount.of(GBP, NOTIONAL * RATE * PAY_YC1), PAYMENT1); NotionalExchange fixedPayment2 = NotionalExchange.of(CurrencyAmount.of(GBP, NOTIONAL * RATE * PAY_YC2), PAYMENT2); NotionalExchange.of(CurrencyAmount.of(GBP, -NOTIONAL * beta1 * PAY_YC1 / fixedYearFraction1), fixingSTART1); NotionalExchange iborPayment12 = NotionalExchange.of(CurrencyAmount.of(GBP, NOTIONAL * PAY_YC1 / fixedYearFraction1), PAYMENT1); LocalDate fixingSTART2 = GBP_LIBOR_3M.calculateEffectiveFromFixing(FIXING2, REF_DATA); double fixedYearFraction2 = GBP_LIBOR_3M.getDayCount().relativeYearFraction(fixingSTART2, NotionalExchange.of(CurrencyAmount.of(GBP, -NOTIONAL * beta2 * PAY_YC2 / fixedYearFraction2), fixingSTART2); NotionalExchange iborPayment22 = NotionalExchange.of(CurrencyAmount.of(GBP, NOTIONAL * PAY_YC2 / fixedYearFraction2), PAYMENT2);
public void test_resolve_fxResetNotionalExchange() { RatePeriodSwapLeg test = RatePeriodSwapLeg.builder() .type(IBOR) .payReceive(RECEIVE) .paymentPeriods(RPP1_FXRESET, RPP2) .initialExchange(true) .intermediateExchange(true) .finalExchange(true) .build(); FxResetNotionalExchange ne1a = FxResetNotionalExchange.of( CurrencyAmount.of(USD, -8000d), DATE_2014_06_30, FxIndexObservation.of(GBP_USD_WM, DATE_2014_06_28, REF_DATA)); FxResetNotionalExchange ne1b = FxResetNotionalExchange.of( CurrencyAmount.of(USD, 8000d), DATE_2014_10_01, FxIndexObservation.of(GBP_USD_WM, DATE_2014_06_28, REF_DATA)); NotionalExchange ne2a = NotionalExchange.of(CurrencyAmount.of(GBP, -6000d), DATE_2014_10_01); NotionalExchange ne2b = NotionalExchange.of(CurrencyAmount.of(GBP, 6000d), DATE_2014_01_02); ResolvedSwapLeg expected = ResolvedSwapLeg.builder() .type(IBOR) .payReceive(RECEIVE) .paymentPeriods(RPP1_FXRESET, RPP2) .paymentEvents(ne1a, ne1b, ne2a, ne2b) .build(); assertEquals(test.resolve(REF_DATA), expected); }
public void test_resolve_createNotionalExchange_initialOnly() { RatePeriodSwapLeg test = RatePeriodSwapLeg.builder() .type(IBOR) .payReceive(RECEIVE) .paymentPeriods(RPP1) .initialExchange(true) .intermediateExchange(false) .finalExchange(false) .build(); ResolvedSwapLeg expected = ResolvedSwapLeg.builder() .type(IBOR) .payReceive(RECEIVE) .paymentPeriods(RPP1) .paymentEvents(NotionalExchange.of(CurrencyAmount.of(GBP, -5000d), DATE_2014_06_30)) .build(); assertEquals(test.resolve(REF_DATA), expected); }
public void test_resolve_createNotionalExchange_finalOnly() { RatePeriodSwapLeg test = RatePeriodSwapLeg.builder() .type(IBOR) .payReceive(RECEIVE) .paymentPeriods(RPP1) .initialExchange(false) .intermediateExchange(false) .finalExchange(true) .build(); ResolvedSwapLeg expected = ResolvedSwapLeg.builder() .type(IBOR) .payReceive(RECEIVE) .paymentPeriods(RPP1) .paymentEvents(NotionalExchange.of(CurrencyAmount.of(GBP, 5000d), DATE_2014_10_01)) .build(); assertEquals(test.resolve(REF_DATA), expected); }
public void test_resolve_createNotionalExchange_noInitial() { RatePeriodSwapLeg test = RatePeriodSwapLeg.builder() .type(IBOR) .payReceive(RECEIVE) .paymentPeriods(RPP1) .initialExchange(false) .intermediateExchange(true) .finalExchange(true) .build(); ResolvedSwapLeg expected = ResolvedSwapLeg.builder() .type(IBOR) .payReceive(RECEIVE) .paymentPeriods(RPP1) .paymentEvents(NotionalExchange.of(CurrencyAmount.of(GBP, 5000d), DATE_2014_10_01)) .build(); assertEquals(test.resolve(REF_DATA), expected); }