public void test_of() { IborRateCalculation test = IborRateCalculation.of(GBP_LIBOR_3M); assertEquals(test.getType(), SwapLegType.IBOR); assertEquals(test.getDayCount(), ACT_365F); assertEquals(test.getIndex(), GBP_LIBOR_3M); assertEquals(test.getResetPeriods(), Optional.empty()); assertEquals(test.getFixingRelativeTo(), PERIOD_START); assertEquals(test.getFixingDateOffset(), GBP_LIBOR_3M.getFixingDateOffset()); assertEquals(test.getNegativeRateMethod(), ALLOW_NEGATIVE); assertEquals(test.getFirstRegularRate(), OptionalDouble.empty()); assertEquals(test.getInitialStub(), Optional.empty()); assertEquals(test.getFinalStub(), Optional.empty()); assertEquals(test.getGearing(), Optional.empty()); assertEquals(test.getSpread(), Optional.empty()); }
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); }
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); }
/** * 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_toLeg() { IborRateSwapLegConvention base = IborRateSwapLegConvention.builder() .index(GBP_LIBOR_3M) .build(); LocalDate startDate = LocalDate.of(2015, 5, 5); LocalDate endDate = LocalDate.of(2020, 5, 5); RateCalculationSwapLeg test = base.toLeg(startDate, endDate, PAY, NOTIONAL_2M); RateCalculationSwapLeg expected = RateCalculationSwapLeg.builder() .payReceive(PAY) .accrualSchedule(PeriodicSchedule.builder() .frequency(P3M) .startDate(startDate) .endDate(endDate) .businessDayAdjustment(BDA_MOD_FOLLOW) .build()) .paymentSchedule(PaymentSchedule.builder() .paymentFrequency(P3M) .paymentDateOffset(DaysAdjustment.NONE) .build()) .notionalSchedule(NotionalSchedule.of(GBP, NOTIONAL_2M)) .calculation(IborRateCalculation.of(GBP_LIBOR_3M)) .build(); assertEquals(test, expected); }
PeriodicSchedule paySchedule = PeriodicSchedule.of(startDate, endDate, frequency, BUSINESS_ADJ, StubConvention.NONE, RollConventions.NONE); IborRateCalculation rateCalculation = IborRateCalculation.of(index); if (putCall.isCall()) { return IborCapFloorLeg.builder()
public void coverage() { IborCapFloorLeg test1 = IborCapFloorLeg.builder() .calculation(RATE_CALCULATION) .floorSchedule(FLOOR) .notional(NOTIONAL) .paymentSchedule(SCHEDULE) .payReceive(RECEIVE) .build(); coverImmutableBean(test1); IborCapFloorLeg test2 = IborCapFloorLeg.builder() .calculation(IborRateCalculation.of(GBP_LIBOR_6M)) .capSchedule(CAP) .notional(ValueSchedule.of(1000)) .paymentDateOffset(PAYMENT_OFFSET) .paymentSchedule(PeriodicSchedule.builder() .startDate(START) .endDate(END) .frequency(Frequency.P6M) .businessDayAdjustment(BUSS_ADJ) .build()) .payReceive(PAY) .build(); coverBeanEquals(test1, test2); }