private static RateCalculation parseOvernightRateCalculation( CsvRow row, String leg, OvernightIndex overnightIndex, OvernightAccrualMethod accrualMethod) { OvernightRateCalculation.Builder builder = OvernightRateCalculation.builder(); // basics builder.index(overnightIndex); builder.accrualMethod(findValue(row, leg, ACCRUAL_METHOD_FIELD) .map(s -> OvernightAccrualMethod.of(s)) .orElse(accrualMethod)); // optionals findValue(row, leg, DAY_COUNT_FIELD) .map(s -> LoaderUtils.parseDayCount(s)) .ifPresent(v -> builder.dayCount(v)); findValue(row, leg, RATE_CUT_OFF_DAYS_FIELD) .map(s -> Integer.valueOf(s)) .ifPresent(v -> builder.rateCutOffDays(v)); findValue(row, leg, NEGATIVE_RATE_METHOD_FIELD).map(s -> NegativeRateMethod.of(s)) .ifPresent(v -> builder.negativeRateMethod(v)); findValue(row, leg, GEARING_FIELD) .map(s -> LoaderUtils.parseDouble(s)) .ifPresent(v -> builder.gearing(ValueSchedule.of(v))); findValue(row, leg, SPREAD_FIELD) .map(s -> LoaderUtils.parseDoublePercent(s)) .ifPresent(v -> builder.spread(ValueSchedule.of(v))); return builder.build(); }
overnightRateBuilder.spread(parseSchedule(el, document)); });
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); }
.accrualMethod(OvernightAccrualMethod.AVERAGED) .rateCutOffDays(0) // Should be 2, put to 0 for comparison .spread(ValueSchedule.of(0.0025)) .build()) .build();
.accrualMethod(getAccrualMethod()) .rateCutOffDays(getRateCutOffDays()) .spread(spread != 0 ? ValueSchedule.of(spread) : null) .build()) .build();
.rateCutOffDays(2) .gearing(ValueSchedule.of(1d, ValueStep.of(2, ValueAdjustment.ofReplace(2d)))) .spread(ValueSchedule.of(0d, ValueStep.of(1, ValueAdjustment.ofReplace(-0.025d)))) .build(); RateAccrualPeriod rap1 = RateAccrualPeriod.builder(ACCRUAL1)
public void coverage() { OvernightRateCalculation test = OvernightRateCalculation.builder() .dayCount(ACT_365F) .index(GBP_SONIA) .build(); coverImmutableBean(test); OvernightRateCalculation test2 = OvernightRateCalculation.builder() .dayCount(ACT_360) .index(USD_FED_FUND) .accrualMethod(AVERAGED) .negativeRateMethod(NOT_NEGATIVE) .rateCutOffDays(2) .gearing(ValueSchedule.of(2d)) .spread(ValueSchedule.of(-0.025d)) .build(); coverBeanEquals(test, test2); }