private PeriodicSchedule createDates(LocalDate start, LocalDate end, LocalDate first, LocalDate last) { return PeriodicSchedule.builder() .startDate(start) .endDate(end) .frequency(P1M) .businessDayAdjustment(BDA) .firstRegularStartDate(first) .lastRegularEndDate(last) .build(); }
@Test(expectedExceptions = ScheduleException.class) public void test_termFrequency_badInitialStub() { PeriodicSchedule defn = PeriodicSchedule.builder() .startDate(JUN_04) .endDate(SEP_17) .frequency(TERM) .businessDayAdjustment(BDA) .stubConvention(STUB_NONE) .rollConvention(DAY_4) .firstRegularStartDate(JUN_17) .lastRegularEndDate(null) .build(); defn.createUnadjustedDates(); }
@Test(expectedExceptions = ScheduleException.class) public void test_both_badStub() { PeriodicSchedule defn = PeriodicSchedule.builder() .startDate(JUN_17) .endDate(SEP_17) .frequency(P1M) .businessDayAdjustment(BDA) .stubConvention(STUB_BOTH) .rollConvention(null) .firstRegularStartDate(JUN_17) .lastRegularEndDate(SEP_17) .build(); defn.createUnadjustedDates(); }
@Test(expectedExceptions = ScheduleException.class) public void test_forwards_badStub() { PeriodicSchedule defn = PeriodicSchedule.builder() .startDate(JUN_17) .endDate(SEP_17) .frequency(P1M) .businessDayAdjustment(BDA) .stubConvention(SHORT_FINAL) .rollConvention(DAY_11) .firstRegularStartDate(null) .lastRegularEndDate(null) .build(); defn.createUnadjustedDates(); }
@Test(expectedExceptions = ScheduleException.class) public void test_backwards_badStub() { PeriodicSchedule defn = PeriodicSchedule.builder() .startDate(JUN_17) .endDate(SEP_17) .frequency(P1M) .businessDayAdjustment(BDA) .stubConvention(SHORT_INITIAL) .rollConvention(DAY_11) .firstRegularStartDate(null) .lastRegularEndDate(null) .build(); defn.createUnadjustedDates(); }
@Test(expectedExceptions = ScheduleException.class) public void test_termFrequency_badFinalStub() { PeriodicSchedule defn = PeriodicSchedule.builder() .startDate(JUN_04) .endDate(SEP_17) .frequency(TERM) .businessDayAdjustment(BDA) .stubConvention(STUB_NONE) .rollConvention(DAY_4) .firstRegularStartDate(null) .lastRegularEndDate(SEP_04) .build(); defn.createUnadjustedDates(); }
@Test(expectedExceptions = ScheduleException.class) public void test_none_badStub() { // Jun 4th to Sep 17th requires a stub, but NONE specified PeriodicSchedule defn = PeriodicSchedule.builder() .startDate(JUN_04) .endDate(SEP_17) .frequency(P1M) .businessDayAdjustment(BDA) .stubConvention(STUB_NONE) .rollConvention(DAY_4) .firstRegularStartDate(null) .lastRegularEndDate(null) .build(); defn.createUnadjustedDates(); }
public void test_collectIndices() { 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(DaysAdjustment.ofBusinessDays(2, GBLO)) .build()) .amount(ValueSchedule.of(123d)) .currency(GBP) .build(); ImmutableSet.Builder<Index> builder = ImmutableSet.builder(); test.collectIndices(builder); assertEquals(builder.build(), ImmutableSet.of()); assertEquals(test.allIndices(), ImmutableSet.of()); }
@Test(expectedExceptions = ScheduleException.class) public void test_none_stubDate() { // Jun 17th to Sep 17th is correct for NONE stub convention, but firstRegularStartDate specified PeriodicSchedule defn = PeriodicSchedule.builder() .startDate(JUN_17) .endDate(SEP_17) .frequency(P1M) .businessDayAdjustment(BDA) .stubConvention(STUB_NONE) .rollConvention(DAY_4) .firstRegularStartDate(JUL_17) .lastRegularEndDate(null) .build(); defn.createUnadjustedDates(); }
public void coverage_builder() { PeriodicSchedule test = PeriodicSchedule.builder() .startDate(JUL_17) .endDate(SEP_17) .frequency(P2M) .businessDayAdjustment(BDA_NONE) .startDateBusinessDayAdjustment(BDA_NONE) .endDateBusinessDayAdjustment(BDA_NONE) .stubConvention(STUB_NONE) .rollConvention(EOM) .firstRegularStartDate(JUL_17) .lastRegularEndDate(SEP_17) .overrideStartDate(AdjustableDate.of(JUL_11)) .build(); assertEquals(test.getStartDate(), JUL_17); assertEquals(test.getEndDate(), SEP_17); assertEquals(test.calculatedStartDate(), AdjustableDate.of(JUL_11, BDA_NONE)); assertEquals(test.calculatedEndDate(), AdjustableDate.of(SEP_17, BDA_NONE)); }
@Test(expectedExceptions = ScheduleException.class, expectedExceptionsMessageRegExp = ".*duplicate adjusted dates.*") public void test_emptyWhenAdjusted_term_createSchedule() { PeriodicSchedule defn = PeriodicSchedule.builder() .startDate(date(2015, 5, 29)) .endDate(date(2015, 5, 31)) .frequency(TERM) .businessDayAdjustment(BDA) .stubConvention(null) .rollConvention(null) .firstRegularStartDate(null) .lastRegularEndDate(null) .build(); defn.createSchedule(REF_DATA); }
@Test(expectedExceptions = ScheduleException.class, expectedExceptionsMessageRegExp = ".*duplicate adjusted dates.*") public void test_emptyWhenAdjusted_term_createAdjustedDates() { PeriodicSchedule defn = PeriodicSchedule.builder() .startDate(date(2015, 5, 29)) .endDate(date(2015, 5, 31)) .frequency(TERM) .businessDayAdjustment(BDA) .stubConvention(null) .rollConvention(null) .firstRegularStartDate(null) .lastRegularEndDate(null) .build(); defn.createAdjustedDates(REF_DATA); }
@Test(expectedExceptions = ScheduleException.class, expectedExceptionsMessageRegExp = ".*duplicate adjusted dates.*") public void test_emptyWhenAdjusted_twoPeriods_createAdjustedDates() { PeriodicSchedule defn = PeriodicSchedule.builder() .startDate(date(2015, 5, 27)) .endDate(date(2015, 5, 31)) .frequency(Frequency.ofDays(2)) .businessDayAdjustment(BDA) .stubConvention(STUB_NONE) .rollConvention(null) .firstRegularStartDate(null) .lastRegularEndDate(null) .build(); defn.createAdjustedDates(REF_DATA); }
@Test(expectedExceptions = ScheduleException.class, expectedExceptionsMessageRegExp = ".*duplicate adjusted dates.*") public void test_emptyWhenAdjusted_twoPeriods_createSchedule() { PeriodicSchedule defn = PeriodicSchedule.builder() .startDate(date(2015, 5, 27)) .endDate(date(2015, 5, 31)) .frequency(Frequency.ofDays(2)) .businessDayAdjustment(BDA) .stubConvention(STUB_NONE) .rollConvention(null) .firstRegularStartDate(null) .lastRegularEndDate(null) .build(); defn.createSchedule(REF_DATA); }
public void test_emptyWhenAdjusted_term_createUnadjustedDates() { PeriodicSchedule defn = PeriodicSchedule.builder() .startDate(date(2015, 5, 29)) .endDate(date(2015, 5, 31)) .frequency(TERM) .businessDayAdjustment(BDA) .stubConvention(null) .rollConvention(null) .firstRegularStartDate(null) .lastRegularEndDate(null) .build(); ImmutableList<LocalDate> test = defn.createUnadjustedDates(); assertEquals(test, list(date(2015, 5, 29), date(2015, 5, 31))); }
public void test_startEndAdjust() { BusinessDayAdjustment bda1 = BusinessDayAdjustment.of(PRECEDING, SAT_SUN); BusinessDayAdjustment bda2 = BusinessDayAdjustment.of(MODIFIED_PRECEDING, SAT_SUN); PeriodicSchedule test = PeriodicSchedule.builder() .startDate(date(2014, 10, 4)) .endDate(date(2015, 4, 4)) .frequency(P3M) .businessDayAdjustment(BDA) .startDateBusinessDayAdjustment(bda1) .endDateBusinessDayAdjustment(bda2) .stubConvention(STUB_NONE) .build(); assertEquals(test.calculatedStartDate(), AdjustableDate.of(date(2014, 10, 4), bda1)); assertEquals(test.calculatedEndDate(), AdjustableDate.of(date(2015, 4, 4), bda2)); assertEquals(test.createUnadjustedDates(), list(date(2014, 10, 4), date(2015, 1, 4), date(2015, 4, 4))); assertEquals(test.createAdjustedDates(REF_DATA), list(date(2014, 10, 3), date(2015, 1, 5), date(2015, 4, 3))); }
public void test_emptyWhenAdjusted_twoPeriods_createUnadjustedDates() { PeriodicSchedule defn = PeriodicSchedule.builder() .startDate(date(2015, 5, 27)) .endDate(date(2015, 5, 31)) .frequency(Frequency.ofDays(2)) .businessDayAdjustment(BDA) .stubConvention(STUB_NONE) .rollConvention(null) .firstRegularStartDate(null) .lastRegularEndDate(null) .build(); ImmutableList<LocalDate> test = defn.createUnadjustedDates(); assertEquals(test, list(date(2015, 5, 27), date(2015, 5, 29), date(2015, 5, 31))); }
private PeriodicSchedule of( LocalDate start, LocalDate end, Frequency freq, BusinessDayAdjustment bda, StubConvention stubConv, RollConvention rollConv, LocalDate firstReg, LocalDate lastReg, BusinessDayAdjustment startBda, BusinessDayAdjustment endBda, AdjustableDate overrideStartDate) { return PeriodicSchedule.builder() .startDate(start) .endDate(end) .frequency(freq) .businessDayAdjustment(bda) .startDateBusinessDayAdjustment(startBda) .endDateBusinessDayAdjustment(endBda) .stubConvention(stubConv) .rollConvention(rollConv) .firstRegularStartDate(firstReg) .lastRegularEndDate(lastReg) .overrideStartDate(overrideStartDate) .build(); }
public void test_serialization() { 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(DaysAdjustment.ofBusinessDays(2, GBLO)) .build()) .amount(ValueSchedule.of(123d)) .currency(GBP) .build(); assertSerialization(test); }
public void test_builder_invalidDateOrder() { // start vs end assertThrowsIllegalArg(() -> createDates(SEP_17, SEP_17, null, null)); assertThrowsIllegalArg(() -> createDates(SEP_17, JUN_04, null, null)); // first/last regular vs start/end assertThrowsIllegalArg(() -> createDates(JUN_04, SEP_17, JUN_03, null)); assertThrowsIllegalArg(() -> createDates(JUN_04, SEP_17, null, SEP_18)); // first regular vs last regular createDates(JUN_04, SEP_05, SEP_05, SEP_05); // allow this assertThrowsIllegalArg(() -> createDates(JUN_04, SEP_17, SEP_05, SEP_04)); // first regular vs override start date assertThrowsIllegalArg(() -> PeriodicSchedule.builder() .startDate(JUN_04) .endDate(SEP_17) .frequency(P1M) .businessDayAdjustment(BDA) .firstRegularStartDate(JUL_17) .overrideStartDate(AdjustableDate.of(AUG_04)) .build()); }