final double[] mainIbor = new double[] {0.0, factor, 0.0};
final double[] floorIbor = new double[] {0.0, 0.0, factor * strike};
final double[] capIbor = new double[] {0.0, 0.0, +50.0};
final AnnuityCouponIborRatchetDefinition ratchetFixedDefinition = AnnuityCouponIborRatchetDefinition.withFirstCouponFixed(SETTLEMENT_DATE, ANNUITY_TENOR, NOTIONAL, IBOR_INDEX, IS_PAYER,
FIRST_CPN_RATE, mainIbor, floorIbor, capIbor, TARGET);
final AnnuityCouponIborRatchet ratchetFixed = ratchetFixedDefinition.toDerivative(REFERENCE_DATE, FIXING_TS, CURVES_NAMES);
final AnnuityCapFloorIborDefinition capDefinition = AnnuityCapFloorIborDefinition.from(SETTLEMENT_DATE, SETTLEMENT_DATE.plus(ANNUITY_TENOR), NOTIONAL, IBOR_INDEX, IS_PAYER, strike, true, TARGET);
final Annuity<? extends Payment> cap = capDefinition.toDerivative(REFERENCE_DATE, FIXING_TS, CURVES_NAMES);
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 CurrencyAmount pvFloorMC = methodMC.presentValue(ratchetFixed, CUR, CURVES_NAMES[0], BUNDLE_HW);
// endTime = System.currentTimeMillis();
// System.out.println("PV Ratchet ibor - Hull-White MC method (" + nbPath + " paths): " + (endTime - startTime) + " ms");
final CapFloorIborHullWhiteMethod methodCapHW = new CapFloorIborHullWhiteMethod();
final AnnuityCouponFixedDefinition fixedDefinition = AnnuityCouponFixedDefinition.from(CUR, SETTLEMENT_DATE, ANNUITY_TENOR, INDEX_TENOR, TARGET, DAY_COUNT, BUSINESS_DAY, IS_EOM, NOTIONAL,
strike, IS_PAYER);
final AnnuityCouponFixed fixed = fixedDefinition.toDerivative(REFERENCE_DATE, CURVES_NAMES);
double pvFlooredExpected = 0.0;
pvFlooredExpected += ratchetFixed.getNthPayment(0).accept(PVC, CURVES);
for (int loopcpn = 1; loopcpn < cap.getNumberOfPayments(); loopcpn++) {
pvFlooredExpected += factor * methodCapHW.presentValue(cap.getNthPayment(loopcpn), BUNDLE_HW).getAmount();
pvFlooredExpected += factor * fixed.getNthPayment(loopcpn).accept(PVC, CURVES);
}
assertEquals("Annuity Ratchet Ibor - Hull-White - Monte Carlo - Degenerate in floor leg", pvFlooredExpected, pvFloorMC.getAmount(), 2.5E+3);