public void test_of_LocalDateRoll_null() { assertThrowsIllegalArg(() -> PeriodicSchedule.of(null, SEP_17, P1M, BDA, SHORT_INITIAL, DAY_17)); assertThrowsIllegalArg(() -> PeriodicSchedule.of(JUN_04, null, P1M, BDA, SHORT_INITIAL, DAY_17)); assertThrowsIllegalArg(() -> PeriodicSchedule.of(JUN_04, SEP_17, null, BDA, SHORT_INITIAL, DAY_17)); assertThrowsIllegalArg(() -> PeriodicSchedule.of(JUN_04, SEP_17, P1M, null, SHORT_INITIAL, DAY_17)); assertThrowsIllegalArg(() -> PeriodicSchedule.of(JUN_04, SEP_17, P1M, BDA, null, DAY_17)); assertThrowsIllegalArg(() -> PeriodicSchedule.of(JUN_04, SEP_17, P1M, BDA, SHORT_INITIAL, null)); }
public void test_of_LocalDateEom_null() { assertThrowsIllegalArg(() -> PeriodicSchedule.of(null, SEP_17, P1M, BDA, SHORT_INITIAL, false)); assertThrowsIllegalArg(() -> PeriodicSchedule.of(JUN_04, null, P1M, BDA, SHORT_INITIAL, false)); assertThrowsIllegalArg(() -> PeriodicSchedule.of(JUN_04, SEP_17, null, BDA, SHORT_INITIAL, false)); assertThrowsIllegalArg(() -> PeriodicSchedule.of(JUN_04, SEP_17, P1M, null, SHORT_INITIAL, false)); assertThrowsIllegalArg(() -> PeriodicSchedule.of(JUN_04, SEP_17, P1M, BDA, null, false)); }
public void test_withDefinition() { PeriodicSchedule defn = PeriodicSchedule.of( date(2014, 6, 30), date(2014, 8, 30), Frequency.P1M, BusinessDayAdjustment.NONE, StubConvention.NONE, false); ScheduleException test = new ScheduleException(defn, "Hello {}", "World"); assertEquals(test.getMessage(), "Hello World"); assertEquals(test.getDefinition(), Optional.of(defn)); }
public void test_of_LocalDateEomTrue() { PeriodicSchedule test = PeriodicSchedule.of(JUN_04, SEP_17, P1M, BDA, SHORT_FINAL, true); assertEquals(test.getStartDate(), JUN_04); assertEquals(test.getEndDate(), SEP_17); assertEquals(test.getFrequency(), P1M); assertEquals(test.getBusinessDayAdjustment(), BDA); assertEquals(test.getStartDateBusinessDayAdjustment(), Optional.empty()); assertEquals(test.getEndDateBusinessDayAdjustment(), Optional.empty()); assertEquals(test.getStubConvention(), Optional.of(SHORT_FINAL)); assertEquals(test.getRollConvention(), Optional.of(EOM)); assertEquals(test.getFirstRegularStartDate(), Optional.empty()); assertEquals(test.getLastRegularEndDate(), Optional.empty()); assertEquals(test.getOverrideStartDate(), Optional.empty()); assertEquals(test.calculatedRollConvention(), DAY_4); assertEquals(test.calculatedFirstRegularStartDate(), JUN_04); assertEquals(test.calculatedLastRegularEndDate(), SEP_17); assertEquals(test.calculatedStartDate(), AdjustableDate.of(JUN_04, BDA)); assertEquals(test.calculatedEndDate(), AdjustableDate.of(SEP_17, BDA)); }
public void test_of_LocalDateRoll() { PeriodicSchedule test = PeriodicSchedule.of(JUN_04, SEP_17, P1M, BDA, SHORT_INITIAL, DAY_17); assertEquals(test.getStartDate(), JUN_04); assertEquals(test.getEndDate(), SEP_17); assertEquals(test.getFrequency(), P1M); assertEquals(test.getBusinessDayAdjustment(), BDA); assertEquals(test.getStartDateBusinessDayAdjustment(), Optional.empty()); assertEquals(test.getEndDateBusinessDayAdjustment(), Optional.empty()); assertEquals(test.getStubConvention(), Optional.of(SHORT_INITIAL)); assertEquals(test.getRollConvention(), Optional.of(DAY_17)); assertEquals(test.getFirstRegularStartDate(), Optional.empty()); assertEquals(test.getLastRegularEndDate(), Optional.empty()); assertEquals(test.getOverrideStartDate(), Optional.empty()); assertEquals(test.calculatedRollConvention(), DAY_17); assertEquals(test.calculatedFirstRegularStartDate(), JUN_04); assertEquals(test.calculatedLastRegularEndDate(), SEP_17); assertEquals(test.calculatedStartDate(), AdjustableDate.of(JUN_04, BDA)); assertEquals(test.calculatedEndDate(), AdjustableDate.of(SEP_17, BDA)); }
public void test_of_LocalDateEomFalse() { PeriodicSchedule test = PeriodicSchedule.of(JUN_04, SEP_17, P1M, BDA, SHORT_INITIAL, false); assertEquals(test.getStartDate(), JUN_04); assertEquals(test.getEndDate(), SEP_17); assertEquals(test.getFrequency(), P1M); assertEquals(test.getBusinessDayAdjustment(), BDA); assertEquals(test.getStartDateBusinessDayAdjustment(), Optional.empty()); assertEquals(test.getEndDateBusinessDayAdjustment(), Optional.empty()); assertEquals(test.getStubConvention(), Optional.of(SHORT_INITIAL)); assertEquals(test.getRollConvention(), Optional.empty()); assertEquals(test.getFirstRegularStartDate(), Optional.empty()); assertEquals(test.getLastRegularEndDate(), Optional.empty()); assertEquals(test.getOverrideStartDate(), Optional.empty()); assertEquals(test.calculatedRollConvention(), DAY_17); assertEquals(test.calculatedFirstRegularStartDate(), JUN_04); assertEquals(test.calculatedLastRegularEndDate(), SEP_17); assertEquals(test.calculatedStartDate(), AdjustableDate.of(JUN_04, BDA)); assertEquals(test.calculatedEndDate(), AdjustableDate.of(SEP_17, BDA)); }
public void coverage() { BusinessDayAdjustment bda = BusinessDayAdjustment.of(FOLLOWING, SAT_SUN); PeriodicSchedule defn = PeriodicSchedule.of( date(2014, JUNE, 4), date(2014, SEPTEMBER, 17), P1M, bda, SHORT_INITIAL, false); coverImmutableBean(defn); }
public void test_serialization() { BusinessDayAdjustment bda = BusinessDayAdjustment.of(FOLLOWING, SAT_SUN); PeriodicSchedule defn = PeriodicSchedule.of( date(2014, JUNE, 4), date(2014, SEPTEMBER, 17), P1M, bda, SHORT_INITIAL, false); assertSerialization(defn); }
LocalDate endDate = LocalDate.of(2020, 10, 20); PeriodicSchedule sch = PeriodicSchedule.of(startDate, endDate, P3M, BusinessDayAdjustment.NONE, SHORT_INITIAL, RollConventions.NONE); Cds test = Cds.builder() .paymentSchedule(sch)
LocalDate endDate = LocalDate.of(2020, 10, 20); PeriodicSchedule sch = PeriodicSchedule.of(startDate, endDate, P3M, BusinessDayAdjustment.NONE, SHORT_INITIAL, RollConventions.NONE); CdsIndex test = CdsIndex.builder() .paymentSchedule(sch)
public void test_createCap() { SurfaceIborCapletFloorletVolatilityBootstrapDefinition base = SurfaceIborCapletFloorletVolatilityBootstrapDefinition.of( NAME, USD_LIBOR_3M, ACT_ACT_ISDA, TIME_SQUARE, DOUBLE_QUADRATIC); LocalDate startDate = LocalDate.of(2012, 4, 20); LocalDate endDate = LocalDate.of(2017, 4, 20); double strike = 0.01; IborCapFloorLeg expected = IborCapFloorLeg.builder() .calculation(IborRateCalculation.of(USD_LIBOR_3M)) .capSchedule(ValueSchedule.of(strike)) .currency(USD_LIBOR_3M.getCurrency()) .notional(ValueSchedule.ALWAYS_1) .paymentDateOffset(DaysAdjustment.NONE) .paymentSchedule( PeriodicSchedule.of( startDate, endDate, Frequency.of(USD_LIBOR_3M.getTenor().getPeriod()), BusinessDayAdjustment.of(BusinessDayConventions.MODIFIED_FOLLOWING, USD_LIBOR_3M.getFixingCalendar()), StubConvention.NONE, RollConventions.NONE)) .payReceive(PayReceive.RECEIVE) .build(); IborCapFloorLeg computed = base.createCap(startDate, endDate, strike); assertEquals(computed, expected); }
/** * Creates a standard cap from start date, end date and strike. * * @param startDate the start date * @param endDate the end date * @param strike the strike * @return the cap */ public default IborCapFloorLeg createCap(LocalDate startDate, LocalDate endDate, double strike) { IborIndex index = getIndex(); return IborCapFloorLeg.builder() .calculation(IborRateCalculation.of(index)) .capSchedule(ValueSchedule.of(strike)) .currency(index.getCurrency()) .notional(ValueSchedule.ALWAYS_1) .paymentSchedule( PeriodicSchedule.of( startDate, endDate, Frequency.of(index.getTenor().getPeriod()), BusinessDayAdjustment.of(BusinessDayConventions.MODIFIED_FOLLOWING, index.getFixingCalendar()), StubConvention.NONE, RollConventions.NONE)) .payReceive(PayReceive.RECEIVE) .build(); }
public void test_createCap() { SabrIborCapletFloorletVolatilityBootstrapDefinition base = SabrIborCapletFloorletVolatilityBootstrapDefinition.ofFixedBeta( NAME, USD_LIBOR_3M, ACT_ACT_ISDA, 0.5, STEP_UPPER, FLAT, FLAT, SabrVolatilityFormula.hagan()); LocalDate startDate = LocalDate.of(2012, 4, 20); LocalDate endDate = LocalDate.of(2017, 4, 20); double strike = 0.01; IborCapFloorLeg expected = IborCapFloorLeg.builder() .calculation(IborRateCalculation.of(USD_LIBOR_3M)) .capSchedule(ValueSchedule.of(strike)) .currency(USD_LIBOR_3M.getCurrency()) .notional(ValueSchedule.ALWAYS_1) .paymentDateOffset(DaysAdjustment.NONE) .paymentSchedule( PeriodicSchedule.of( startDate, endDate, Frequency.of(USD_LIBOR_3M.getTenor().getPeriod()), BusinessDayAdjustment.of(BusinessDayConventions.MODIFIED_FOLLOWING, USD_LIBOR_3M.getFixingCalendar()), StubConvention.NONE, RollConventions.NONE)) .payReceive(PayReceive.RECEIVE) .build(); IborCapFloorLeg computed = base.createCap(startDate, endDate, strike); assertEquals(computed, expected); }
public void coverage() { coverImmutableBean(PRODUCT); CdsIndex other = CdsIndex.builder() .buySell(SELL) .cdsIndexId(StandardId.of("OG", "AA-INDEX")) .legalEntityIds(ImmutableList.of(StandardId.of("OG", "ABC1"), StandardId.of("OG", "ABC2"))) .currency(JPY) .notional(1d) .paymentSchedule( PeriodicSchedule.of( LocalDate.of(2014, 1, 4), LocalDate.of(2020, 11, 20), P6M, BusinessDayAdjustment.of(BusinessDayConventions.FOLLOWING, JPTO), StubConvention.SHORT_FINAL, RollConventions.NONE)) .fixedRate(0.01) .dayCount(ACT_365F) .paymentOnDefault(PaymentOnDefault.NONE) .protectionStart(ProtectionStartOfDay.NONE) .settlementDateOffset(DaysAdjustment.NONE) .stepinDateOffset(DaysAdjustment.NONE) .build(); coverBeanEquals(PRODUCT, other); }
static FixedCouponBond sut2() { BusinessDayAdjustment adj = BusinessDayAdjustment.of(MODIFIED_FOLLOWING, SAT_SUN); PeriodicSchedule sche = PeriodicSchedule.of( START_DATE, END_DATE, Frequency.P12M, adj, StubConvention.SHORT_INITIAL, true); return FixedCouponBond.builder() .securityId(SECURITY_ID2) .dayCount(DayCounts.ACT_360) .fixedRate(0.005) .legalEntityId(LegalEntityId.of("OG-Ticker", "BUN EUR 2")) .currency(GBP) .notional(1.0e6) .accrualSchedule(sche) .settlementDateOffset(DaysAdjustment.ofBusinessDays(2, SAT_SUN)) .yieldConvention(FixedCouponBondYieldConvention.GB_BUMP_DMO) .build(); }
PeriodicSchedule.of(startDate, endDate, frequency, BUSINESS_ADJ, StubConvention.NONE, RollConventions.NONE); return RateCalculationSwapLeg.builder() .payReceive(payRec)
static CapitalIndexedBond sut2() { return CapitalIndexedBond.builder() .securityId(SECURITY_ID2) .notional(5.0e7) .currency(GBP) .dayCount(NL_365) .rateCalculation( InflationRateCalculation.builder() .index(GB_RPI) .lag(Period.ofMonths(2)) .indexCalculationMethod(INTERPOLATED) .firstIndexValue(124.556) .build()) .exCouponPeriod(EX_COUPON) .legalEntityId(LegalEntityId.of("OG-Ticker", "US-Govt-1")) .yieldConvention(GB_IL_FLOAT) .settlementDateOffset(DaysAdjustment.ofBusinessDays(2, GBLO)) .accrualSchedule( PeriodicSchedule.of( START, END, FREQUENCY, BusinessDayAdjustment.of(BusinessDayConventions.FOLLOWING, GBLO), StubConvention.NONE, RollConventions.NONE)) .build(); }
PeriodicSchedule.of(startDate, endDate, frequency, BUSINESS_ADJ, StubConvention.NONE, RollConventions.NONE); IborRateCalculation rateCalculation = IborRateCalculation.of(index); if (putCall.isCall()) {
public void test_builder_fail() { // index is null assertThrowsIllegalArg(() -> CmsLeg.builder() .capSchedule(CAP) .notional(NOTIONAL) .payReceive(RECEIVE) .paymentSchedule(SCHEDULE_EUR) .build()); // floorSchedule and capSchedule are present assertThrowsIllegalArg(() -> CmsLeg.builder() .capSchedule(CAP) .floorSchedule(FLOOR) .index(INDEX) .notional(NOTIONAL) .payReceive(RECEIVE) .paymentSchedule(SCHEDULE_EUR) .build()); // stub is on assertThrowsIllegalArg(() -> CmsLeg .builder() .index(INDEX) .notional(NOTIONAL) .payReceive(RECEIVE) .paymentSchedule( PeriodicSchedule.of(START, END, FREQUENCY, BUSS_ADJ_EUR, StubConvention.SHORT_INITIAL, RollConventions.NONE)) .build()); }