.frequency(Frequency.P3M) .businessDayAdjustment(BDA) .firstRegularStartDate(firstRegularStartDate) .overrideStartDate(AdjustableDate.of(overrideStartDate)) .build();
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)); }
public void cds01() { String location = "classpath:com/opengamma/strata/loader/fpml/cd-ex01-long-asia-corp-fixreg.xml"; ByteSource resource = ResourceLocator.of(location).getByteSource(); List<Trade> trades = FpmlDocumentParser.of(FpmlPartySelector.matching("Party2")).parseTrades(resource); assertEquals(trades.size(), 1); CdsTrade cdsTrade = (CdsTrade) trades.get(0); assertEquals(cdsTrade.getInfo().getTradeDate(), Optional.of(date(2002, 12, 4))); Cds expected = Cds.builder() .buySell(BUY) .legalEntityId(StandardId.of("http://www.fpml.org/spec/2003/entity-id-RED-1-0", "004CC9")) .currency(JPY) .notional(500000000d) .paymentSchedule(PeriodicSchedule.builder() .startDate(date(2002, 12, 5)) .endDate(date(2007, 12, 5)) .startDateBusinessDayAdjustment(BusinessDayAdjustment.NONE) .endDateBusinessDayAdjustment(BusinessDayAdjustment.of(MODIFIED_FOLLOWING, GBLO_USNY_JPTO)) .businessDayAdjustment(BusinessDayAdjustment.of(MODIFIED_FOLLOWING, GBLO_USNY_JPTO)) .firstRegularStartDate(date(2003, 3, 5)) .frequency(Frequency.P3M) .rollConvention(RollConventions.DAY_5) .build()) .fixedRate(0.007) .dayCount(ACT_360) .build(); assertEqualsBean(cdsTrade.getProduct(), expected); assertEquals(cdsTrade.getUpfrontFee().isPresent(), false); }
@Test(dataProvider = "generation") public void test_monthly_adjusted( LocalDate start, LocalDate end, Frequency freq, StubConvention stubConv, RollConvention rollConv, BusinessDayAdjustment businessDayAdjustment, LocalDate firstReg, LocalDate lastReg, BusinessDayAdjustment startBusDayAdjustment, List<LocalDate> unadjusted, List<LocalDate> adjusted, RollConvention expRoll) { PeriodicSchedule defn = PeriodicSchedule.builder() .startDate(start) .endDate(end) .frequency(freq) .startDateBusinessDayAdjustment(startBusDayAdjustment) .businessDayAdjustment(businessDayAdjustment) .stubConvention(stubConv) .rollConvention(rollConv) .firstRegularStartDate(firstReg) .lastRegularEndDate(lastReg) .build(); ImmutableList<LocalDate> test = defn.createAdjustedDates(REF_DATA); assertEquals(test, adjusted); }
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()); }
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(); }
@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(); }
@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_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))); }
@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(); }
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))); }
@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); }
@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_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) 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, 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) 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_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_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(); }
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(); }