public void test_toLeg_withSpread() { OvernightRateSwapLegConvention base = OvernightRateSwapLegConvention.builder().index(GBP_SONIA).accrualMethod(AVERAGED).build(); LocalDate startDate = LocalDate.of(2015, 5, 5); LocalDate endDate = LocalDate.of(2020, 5, 5); RateCalculationSwapLeg test = base.toLeg(startDate, endDate, PAY, NOTIONAL_2M, 0.25d); RateCalculationSwapLeg expected = RateCalculationSwapLeg.builder() .payReceive(PAY) .accrualSchedule( PeriodicSchedule.builder() .frequency(TERM) .startDate(startDate) .endDate(endDate) .businessDayAdjustment(BDA_MOD_FOLLOW) .build()) .paymentSchedule( PaymentSchedule.builder() .paymentFrequency(TERM) .paymentDateOffset(DaysAdjustment.NONE) .build()) .notionalSchedule(NotionalSchedule.of(GBP, NOTIONAL_2M)) .calculation( OvernightRateCalculation.builder() .index(GBP_SONIA) .accrualMethod(AVERAGED) .spread(ValueSchedule.of(0.25d)) .build()) .build(); assertEquals(test, expected); }
// ------------------------------------------------------------------------- public void coverage() { OvernightRateSwapLegConvention test = OvernightRateSwapLegConvention.builder().index(GBP_SONIA).accrualMethod(COMPOUNDED).build(); coverImmutableBean(test); OvernightRateSwapLegConvention test2 = OvernightRateSwapLegConvention.builder() .index(USD_FED_FUND) .accrualMethod(AVERAGED) .rateCutOffDays(2) .currency(USD) .dayCount(ACT_360) .accrualFrequency(P6M) .accrualBusinessDayAdjustment(BDA_FOLLOW) .startDateBusinessDayAdjustment(BDA_FOLLOW) .endDateBusinessDayAdjustment(BDA_FOLLOW) .stubConvention(LONG_INITIAL) .rollConvention(RollConventions.EOM) .paymentFrequency(P6M) .paymentDateOffset(PLUS_TWO_DAYS) .build(); coverBeanEquals(test, test2); }
// ------------------------------------------------------------------------- public void test_builder_notEnoughData() { assertThrowsIllegalArg(() -> OvernightRateSwapLegConvention.builder().build()); }
public void test_of_method() { OvernightRateSwapLegConvention test = OvernightRateSwapLegConvention.of(GBP_SONIA, P12M, 2, AVERAGED); assertEquals(test.getIndex(), GBP_SONIA); assertEquals(test.getAccrualMethod(), AVERAGED); assertEquals(test.getRateCutOffDays(), 0); assertEquals(test.getCurrency(), GBP); assertEquals(test.getDayCount(), ACT_365F); assertEquals(test.getAccrualFrequency(), P12M); assertEquals(test.getAccrualBusinessDayAdjustment(), BDA_MOD_FOLLOW); assertEquals(test.getStartDateBusinessDayAdjustment(), BDA_MOD_FOLLOW); assertEquals(test.getEndDateBusinessDayAdjustment(), BDA_MOD_FOLLOW); assertEquals(test.getStubConvention(), StubConvention.SHORT_INITIAL); assertEquals(test.getRollConvention(), RollConventions.NONE); assertEquals(test.getPaymentFrequency(), P12M); assertEquals( test.getPaymentDateOffset(), DaysAdjustment.ofBusinessDays(2, GBP_SONIA.getFixingCalendar())); assertEquals(test.getCompoundingMethod(), CompoundingMethod.NONE); }
public void test_serialization() { OvernightRateSwapLegConvention test = OvernightRateSwapLegConvention.of(GBP_SONIA, P12M, 2); assertSerialization(test); }
public void test_expandAllSpecified() { OvernightRateSwapLegConvention test = OvernightRateSwapLegConvention.builder() .index(GBP_SONIA) .accrualMethod(COMPOUNDED) .rateCutOffDays(2) .currency(USD) .dayCount(ACT_360) .accrualFrequency(P6M) .accrualBusinessDayAdjustment(BDA_FOLLOW) .startDateBusinessDayAdjustment(BDA_FOLLOW) .endDateBusinessDayAdjustment(BDA_FOLLOW) .stubConvention(LONG_INITIAL) .rollConvention(RollConventions.EOM) .paymentFrequency(P6M) .paymentDateOffset(PLUS_TWO_DAYS) .compoundingMethod(CompoundingMethod.FLAT) .build(); assertEquals(test.getIndex(), GBP_SONIA); assertEquals(test.getAccrualMethod(), COMPOUNDED); assertEquals(test.getRateCutOffDays(), 2); assertEquals(test.getCurrency(), USD); assertEquals(test.getDayCount(), ACT_360); assertEquals(test.getAccrualFrequency(), P6M); assertEquals(test.getAccrualBusinessDayAdjustment(), BDA_FOLLOW); assertEquals(test.getStartDateBusinessDayAdjustment(), BDA_FOLLOW); assertEquals(test.getEndDateBusinessDayAdjustment(), BDA_FOLLOW); assertEquals(test.getStubConvention(), StubConvention.LONG_INITIAL); assertEquals(test.getRollConvention(), RollConventions.EOM); assertEquals(test.getPaymentFrequency(), P6M); assertEquals(test.getPaymentDateOffset(), PLUS_TWO_DAYS); assertEquals(test.getCompoundingMethod(), CompoundingMethod.FLAT); }