/** * Obtains an instance representing an amount where the date is fixed. * <p> * Whether the payment is pay or receive is determined by the sign of the specified amount. * * @param value the amount of the payment * @param date the date that the payment is made * @return the adjustable payment instance */ public static AdjustablePayment of(CurrencyAmount value, LocalDate date) { return new AdjustablePayment(value, AdjustableDate.of(date)); }
/** * Calculates the applicable end date. * <p> * The result combines the end date and the appropriate business day adjustment. * * @return the calculated end date */ public AdjustableDate calculatedEndDate() { return AdjustableDate.of(endDate, calculatedEndDateBusinessDayAdjustment()); }
@Override public AdjustableDate getStartDate() { return AdjustableDate.of(paymentPeriods.get(0).getStartDate()); }
@Override public AdjustableDate getEndDate() { return AdjustableDate.of(paymentPeriods.get(paymentPeriods.size() - 1).getEndDate()); }
/** * Obtains an instance representing an amount to be paid where the date is fixed. * <p> * The sign of the amount will be normalized to be negative, indicating a payment. * * @param value the amount of the payment * @param date the date that the payment is made * @return the adjustable payment instance */ public static AdjustablePayment ofPay(CurrencyAmount value, LocalDate date) { return new AdjustablePayment(value.negative(), AdjustableDate.of(date)); }
@Test(dataProvider = "adjusted") public void test_adjusted(LocalDate date, LocalDate expected) { AdjustableDate test = AdjustableDate.of(date, BDA_FOLLOW_SAT_SUN); assertEquals(test.adjusted(REF_DATA), expected); }
public void test_of_2args_withNoAdjustment() { AdjustableDate test = AdjustableDate.of(FRI_2014_07_11, BDA_NONE); assertEquals(test.getUnadjusted(), FRI_2014_07_11); assertEquals(test.getAdjustment(), BDA_NONE); assertEquals(test.toString(), "2014-07-11"); assertEquals(test.adjusted(REF_DATA), FRI_2014_07_11); }
public void formatForCsv() { AdjustableDate date = AdjustableDate.of(date(2016, 6, 30), BusinessDayAdjustment.of(MODIFIED_FOLLOWING, SAT_SUN)); assertThat(AdjustableDateValueFormatter.INSTANCE.formatForCsv(date)).isEqualTo("2016-06-30"); } }
public void test_of_1arg() { AdjustableDate test = AdjustableDate.of(FRI_2014_07_11); assertEquals(test.getUnadjusted(), FRI_2014_07_11); assertEquals(test.getAdjustment(), BDA_NONE); assertEquals(test.toString(), "2014-07-11"); assertEquals(test.adjusted(REF_DATA), FRI_2014_07_11); }
public void test_of_2args_withAdjustment() { AdjustableDate test = AdjustableDate.of(FRI_2014_07_11, BDA_FOLLOW_SAT_SUN); assertEquals(test.getUnadjusted(), FRI_2014_07_11); assertEquals(test.getAdjustment(), BDA_FOLLOW_SAT_SUN); assertEquals(test.toString(), "2014-07-11 adjusted by Following using calendar Sat/Sun"); assertEquals(test.adjusted(REF_DATA), FRI_2014_07_11); }
public void test_getEndDate() { SwapLeg leg1 = MockSwapLeg.of(FIXED, PAY, date(2015, 6, 29), date(2017, 6, 30), Currency.USD); SwapLeg leg2 = MockSwapLeg.of(FIXED, RECEIVE, date(2015, 6, 30), date(2017, 6, 29), Currency.USD); assertEquals(Swap.of(leg1).getEndDate(), AdjustableDate.of(date(2017, 6, 30))); assertEquals(Swap.of(leg2).getEndDate(), AdjustableDate.of(date(2017, 6, 29))); assertEquals(Swap.of(leg1, leg2).getEndDate(), AdjustableDate.of(date(2017, 6, 30))); assertEquals(Swap.of(leg2, leg1).getEndDate(), AdjustableDate.of(date(2017, 6, 30))); }
static Swaption sut2() { return Swaption.builder() .expiryDate(AdjustableDate.of(LocalDate.of(2014, 6, 10), ADJUSTMENT)) .expiryTime(LocalTime.of(14, 0)) .expiryZone(ZoneId.of("GMT")) .longShort(SHORT) .swaptionSettlement(CASH_SETTLE) .underlying(FixedIborSwapConventions.USD_FIXED_6M_LIBOR_3M .createTrade(LocalDate.of(2014, 6, 10), Tenor.TENOR_10Y, BuySell.BUY, 1d, FIXED_RATE, REF_DATA).getProduct()) .build(); }
public void test_resolve_pay() { BulletPayment test = BulletPayment.builder() .payReceive(PayReceive.PAY) .value(GBP_P1000) .date(AdjustableDate.of(DATE_2015_06_30)) .build(); ResolvedBulletPayment expected = ResolvedBulletPayment.of(Payment.of(GBP_M1000, DATE_2015_06_30)); assertEquals(test.resolve(REF_DATA), expected); }
public void test_resolve_receive() { BulletPayment test = BulletPayment.builder() .payReceive(PayReceive.RECEIVE) .value(GBP_P1000) .date(AdjustableDate.of(DATE_2015_06_30)) .build(); ResolvedBulletPayment expected = ResolvedBulletPayment.of(Payment.of(GBP_P1000, DATE_2015_06_30)); assertEquals(test.resolve(REF_DATA), expected); }
public void test_serialization() { BulletPayment test = BulletPayment.builder() .payReceive(PayReceive.PAY) .value(GBP_P1000) .date(AdjustableDate.of(DATE_2015_06_30)) .build(); assertSerialization(test); }
public void test_builder_expiryAfterStart() { assertThrowsIllegalArg(() -> Swaption.builder() .expiryDate(AdjustableDate.of(LocalDate.of(2014, 6, 17), ADJUSTMENT)) .expiryTime(EXPIRY_TIME) .expiryZone(ZONE) .longShort(LONG) .swaptionSettlement(PHYSICAL_SETTLE) .underlying(SWAP) .build()); }
public void test_physicalSettlement() { Swaption swaption = Swaption .builder() .expiryDate(AdjustableDate.of(MATURITY, BDA_MF)) .expiryTime(LocalTime.NOON) .expiryZone(ZoneOffset.UTC) .swaptionSettlement(PhysicalSwaptionSettlement.DEFAULT) .longShort(LONG) .underlying(SWAP_PAY) .build(); assertThrowsIllegalArg(() -> PRICER.impliedVolatility(swaption.resolve(REF_DATA), RATE_PROVIDER, VOLS)); }
public void test_physicalSettlement() { Swaption swaption = Swaption.builder() .swaptionSettlement(PhysicalSwaptionSettlement.DEFAULT) .expiryDate(AdjustableDate.of(SWAPTION_EXERCISE_DATE)) .expiryTime(SWAPTION_EXPIRY_TIME) .expiryZone(SWAPTION_EXPIRY_ZONE) .longShort(LongShort.LONG) .underlying(SWAP_REC) .build(); assertThrowsIllegalArg(() -> PRICER_SWAPTION.presentValue(swaption.resolve(REF_DATA), RATE_PROVIDER, VOLS)); }