final double[] floorIbor = new double[] {0.0, 0.0, factor * strike};
final double[] capIbor = new double[] {0.0, 0.0, 100.0};
final AnnuityCouponIborRatchetDefinition ratchetIborDefinition = AnnuityCouponIborRatchetDefinition.withFirstCouponIborGearing(SETTLEMENT_DATE, ANNUITY_TENOR, NOTIONAL, EURIBOR3M, IS_PAYER,
mainIbor, floorIbor, capIbor, TARGET);
final DoubleTimeSeries<ZonedDateTime> fixing = ImmutableZonedDateTimeDoubleTimeSeries.ofUTC(new ZonedDateTime[] {referenceDate}, new double[] {FIRST_CPN_RATE});
final AnnuityCouponIborRatchet ratchetIbor = ratchetIborDefinition.toDerivative(referenceDate, fixing);
final AnnuityCapFloorIborDefinition capDefinition = AnnuityCapFloorIborDefinition.from(SETTLEMENT_DATE, SETTLEMENT_DATE.plus(ANNUITY_TENOR), NOTIONAL, EURIBOR3M, IS_PAYER, strike, true, TARGET);
final Annuity<? extends Payment> cap = capDefinition.toDerivative(referenceDate, fixing);
final int nbPath = 100000;
HullWhiteMonteCarloMethod methodMC;
methodMC = new HullWhiteMonteCarloMethod(new NormalRandomNumberGenerator(0.0, 1.0, new MersenneTwister()), nbPath);
// long startTime, endTime;
// startTime = System.currentTimeMillis();
final MultipleCurrencyAmount pvFlooredMC = methodMC.presentValue(ratchetIbor, CUR, HW_MULTICURVES);
// endTime = System.currentTimeMillis();
// System.out.println("PV Ratchet ibor - Hull-White MC method (" + nbPath + " paths): " + (endTime - startTime) + " ms");
final AnnuityCouponFixedDefinition fixedDefinition = AnnuityCouponFixedDefinition.from(CUR, SETTLEMENT_DATE, ANNUITY_TENOR, EURIBOR3M.getTenor(), TARGET, EURIBOR3M.getDayCount(),
EURIBOR3M.getBusinessDayConvention(), EURIBOR3M.isEndOfMonth(), NOTIONAL, strike, IS_PAYER);
final AnnuityCouponFixed fixed = fixedDefinition.toDerivative(referenceDate);
MultipleCurrencyAmount pvFlooredExpected = MultipleCurrencyAmount.of(CUR, 0.0);
pvFlooredExpected = pvFlooredExpected.plus(ratchetIbor.getNthPayment(0).accept(PVDC, MULTICURVES));
for (int loopcpn = 1; loopcpn < cap.getNumberOfPayments(); loopcpn++) {
pvFlooredExpected = pvFlooredExpected.plus(METHOD_HW_CAP.presentValue((CapFloorIbor) cap.getNthPayment(loopcpn), HW_MULTICURVES).multipliedBy(factor));
pvFlooredExpected = pvFlooredExpected.plus(fixed.getNthPayment(loopcpn).accept(PVDC, MULTICURVES).multipliedBy(factor));
}
assertEquals("Annuity Ratchet Ibor - Hull-White - Monte Carlo - Degenerate in floor leg", pvFlooredExpected.getAmount(CUR), pvFlooredMC.getAmount(CUR), 2.5E+3);