Examples of LiborMarketModelMonteCarloMethod


Examples of com.opengamma.analytics.financial.montecarlo.LiborMarketModelMonteCarloMethod

  public void presentValueIbor() {
    final ZonedDateTime referenceDate = DateUtils.getUTCDate(2011, 8, 18);
    final AnnuityCouponIborRatchet annuityRatchetIbor = ANNUITY_RATCHET_IBOR_DEFINITION.toDerivative(referenceDate, FIXING_TS, CURVES_NAMES);
    final LiborMarketModelDisplacedDiffusionParameters parameterLMM = TestsDataSetLiborMarketModelDisplacedDiffusion.createLMMParameters(referenceDate, ANNUITY_RATCHET_FIXED_DEFINITION);
    final LiborMarketModelDisplacedDiffusionDataBundle bundleLMM = new LiborMarketModelDisplacedDiffusionDataBundle(parameterLMM, CURVES);
    final LiborMarketModelMonteCarloMethod methodMC = new LiborMarketModelMonteCarloMethod(new NormalRandomNumberGenerator(0.0, 1.0, new MersenneTwister()), NB_PATH);
    // Seed fixed to the DEFAULT_SEED for testing purposes.
    final CurrencyAmount pvMC = methodMC.presentValue(annuityRatchetIbor, EUR, CURVES.getCurve(CURVES_NAMES[0]), bundleLMM);
    final double pvMCPreviousRun = 8259675.715;
    assertEquals("Annuity Ratchet Ibor - LMM - Monte Carlo", pvMCPreviousRun, pvMC.getAmount(), 1.0E-2);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.montecarlo.LiborMarketModelMonteCarloMethod

  /**
   * Test the Ratchet present value in the degenerate case where the coupon are fixed (floor=cap).
   */
  public void presentValueFixedLeg() {
    final int nbPath = 12500;
    final LiborMarketModelMonteCarloMethod methodMC = new LiborMarketModelMonteCarloMethod(new NormalRandomNumberGenerator(0.0, 1.0, new MersenneTwister()), nbPath);
    final double[] mainFixed = new double[] {0.0, 0.0, 0.0};
    final double[] floorFixed = new double[] {0.0, 0.0, FIRST_CPN_RATE};
    final double[] capFixed = new double[] {0.0, 0.0, FIRST_CPN_RATE};
    final AnnuityCouponIborRatchetDefinition ratchetFixedDefinition = AnnuityCouponIborRatchetDefinition.withFirstCouponFixed(SETTLEMENT_DATE, ANNUITY_TENOR, NOTIONAL, INDEX_EURIBOR3M, IS_PAYER,
        FIRST_CPN_RATE, mainFixed, floorFixed, capFixed, TARGET);
    final AnnuityCouponIborRatchet ratchetFixed = ratchetFixedDefinition.toDerivative(REFERENCE_DATE, FIXING_TS, CURVES_NAMES);
    final AnnuityCouponFixedDefinition fixedDefinition = AnnuityCouponFixedDefinition.from(EUR, SETTLEMENT_DATE, ANNUITY_TENOR, INDEX_EURIBOR3M.getTenor(), TARGET, INDEX_EURIBOR3M.getDayCount(),
        INDEX_EURIBOR3M.getBusinessDayConvention(), INDEX_EURIBOR3M.isEndOfMonth(), NOTIONAL, FIRST_CPN_RATE, IS_PAYER);
    final AnnuityCouponFixed fixed = fixedDefinition.toDerivative(REFERENCE_DATE, CURVES_NAMES);
    final double pvFixedExpected = fixed.accept(PVC, CURVES);
    final CurrencyAmount pvFixedMC = methodMC.presentValue(ratchetFixed, EUR, CURVES.getCurve(CURVES_NAMES[0]), BUNDLE_LMM);
    assertEquals("Annuity Ratchet Ibor - LMM - Monte Carlo - Degenerate in Fixed leg", pvFixedExpected, pvFixedMC.getAmount(), 1.0E+2);
    // For 500,000 path the difference is 1.65
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.montecarlo.LiborMarketModelMonteCarloMethod

    for (int loopcpn = 1; loopcpn < ibor.getNumberOfPayments(); loopcpn++) {
      iborFirstFixed[loopcpn] = ibor.getNthPayment(loopcpn);
    }
    final LiborMarketModelDisplacedDiffusionParameters parameterLMM = TestsDataSetLiborMarketModelDisplacedDiffusion.createLMMParameters(REFERENCE_DATE, ratchetFixedDefinition);
    final LiborMarketModelDisplacedDiffusionDataBundle bundleLMM = new LiborMarketModelDisplacedDiffusionDataBundle(parameterLMM, CURVES);
    final LiborMarketModelMonteCarloMethod methodMC = new LiborMarketModelMonteCarloMethod(new NormalRandomNumberGenerator(0.0, 1.0, new MersenneTwister()), nbPath);
    final CurrencyAmount pvIborMC = methodMC.presentValue(ratchetFixed, EUR, CURVES.getCurve(CURVES_NAMES[0]), bundleLMM);
    final double pvIborExpected = new Annuity<Payment>(iborFirstFixed).accept(PVC, CURVES);
    assertEquals("Annuity Ratchet Ibor - Hull-White - Monte Carlo - Degenerate in Ibor leg", pvIborExpected, pvIborMC.getAmount(), 1.0E+4);
    // For 500,000 path the difference is 755.92
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.montecarlo.LiborMarketModelMonteCarloMethod

    final AnnuityCouponIborRatchetDefinition ratchetFixedDefinition = AnnuityCouponIborRatchetDefinition.withFirstCouponFixed(SETTLEMENT_DATE, ANNUITY_TENOR, NOTIONAL, INDEX_EURIBOR3M, 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, INDEX_EURIBOR3M, IS_PAYER, strike, true, TARGET);
    final Annuity<? extends Payment> cap = capDefinition.toDerivative(REFERENCE_DATE, FIXING_TS, CURVES_NAMES);
    final LiborMarketModelMonteCarloMethod methodMC = new LiborMarketModelMonteCarloMethod(new NormalRandomNumberGenerator(0.0, 1.0, new MersenneTwister()), nbPath);
    final CapFloorIborLMMDDMethod methodCapLMM = new CapFloorIborLMMDDMethod();
    final AnnuityCouponFixedDefinition fixedDefinition = AnnuityCouponFixedDefinition.from(EUR, SETTLEMENT_DATE, ANNUITY_TENOR, INDEX_EURIBOR3M.getTenor(), TARGET, INDEX_EURIBOR3M.getDayCount(),
        INDEX_EURIBOR3M.getBusinessDayConvention(), INDEX_EURIBOR3M.isEndOfMonth(), 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 * methodCapLMM.presentValue(cap.getNthPayment(loopcpn), BUNDLE_LMM).getAmount();
      pvFlooredExpected += factor * fixed.getNthPayment(loopcpn).accept(PVC, CURVES);
    }
    final CurrencyAmount pvFloorMC = methodMC.presentValue(ratchetFixed, EUR, CURVES.getCurve(CURVES_NAMES[0]), BUNDLE_LMM);
    assertEquals("Annuity Ratchet Ibor - Hull-White - LMM - Degenerate in floor leg", pvFlooredExpected, pvFloorMC.getAmount(), 2.5E+3);
    // For 500,000 path the difference is 561.70
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.montecarlo.LiborMarketModelMonteCarloMethod

        INDEX_EURIBOR3M, IS_PAYER, MAIN_COEF, FLOOR_COEF, CAP_COEF, TARGET);
    final ZonedDateTime referenceDate = DateUtils.getUTCDate(2011, 8, 18);
    final LiborMarketModelDisplacedDiffusionParameters parameterLMM = TestsDataSetLiborMarketModelDisplacedDiffusion.createLMMParameters(referenceDate, annuityRatchetIbor20Definition);
    final LiborMarketModelDisplacedDiffusionDataBundle bundleLMM = new LiborMarketModelDisplacedDiffusionDataBundle(parameterLMM, CURVES);
    final AnnuityCouponIborRatchet annuityRatchetIbor20 = annuityRatchetIbor20Definition.toDerivative(referenceDate, FIXING_TS, CURVES_NAMES);
    final LiborMarketModelMonteCarloMethod methodMC = new LiborMarketModelMonteCarloMethod(new NormalRandomNumberGenerator(0.0, 1.0, new MersenneTwister()), nbPath);
    final CurrencyAmount[] pvMC = new CurrencyAmount[nbTest];
    //    InterestRateCurveSensitivity[] pvcsMC = new InterestRateCurveSensitivity[nbTest];

    startTime = System.currentTimeMillis();
    for (int looptest = 0; looptest < nbTest; looptest++) {
      pvMC[looptest] = methodMC.presentValue(annuityRatchetIbor20, EUR, CURVES.getCurve(CURVES_NAMES[0]), bundleLMM);
    }
    endTime = System.currentTimeMillis();
    System.out.println(nbTest + " pv Ratchet Ibor LMM MC method: " + (endTime - startTime) + " ms");
    // Performance note: HW MC price (12500 paths): 9-Sep-11: On Mac Pro 3.2 GHz Quad-Core Intel Xeon: 2700 ms for 5 Ratchet (20 coupons each).
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.montecarlo.LiborMarketModelMonteCarloMethod

  /**
   * Test the present value.
   */
  public void presentValueMCMultiCurves() {
    final YieldAndDiscountCurve dsc = CURVES.getCurve(CURVES_NAME[0]);
    LiborMarketModelMonteCarloMethod methodLmmMc;
    methodLmmMc = new LiborMarketModelMonteCarloMethod(new NormalRandomNumberGenerator(0.0, 1.0, new MersenneTwister()), NB_PATH);
    final CurrencyAmount pvLastMC = methodLmmMc.presentValue(CAP_LAST, CUR, dsc, BUNDLE_LMM);
    final double pvLastPreviousRun = 190791.921; // 12500 paths - 1Y jump
    assertEquals("Cap/floor: LMM pricing by Monte Carlo", pvLastPreviousRun, pvLastMC.getAmount(), 1E-2);
    final CurrencyAmount pvLastExplicit = METHOD_LMM_CAP.presentValue(CAP_LAST, BUNDLE_LMM);
    assertEquals("Cap/floor: LMM pricing by Monte Carlo", pvLastExplicit.getAmount(), pvLastMC.getAmount(), 2.0E+2);
    methodLmmMc = new LiborMarketModelMonteCarloMethod(new NormalRandomNumberGenerator(0.0, 1.0, new MersenneTwister()), NB_PATH);
    final CurrencyAmount pv6MC = methodLmmMc.presentValue(CAP_6, CUR, dsc, BUNDLE_LMM);
    final double pv6PreviousRun = 159886.927; // 12500 paths - 1Y jump
    assertEquals("Cap/floor: LMM pricing by Monte Carlo", pv6PreviousRun, pv6MC.getAmount(), 1E-2);
    final CurrencyAmount pv6Explicit = METHOD_LMM_CAP.presentValue(CAP_6, BUNDLE_LMM);
    assertEquals("Cap/floor: LMM pricing by Monte Carlo", pv6Explicit.getAmount(), pv6MC.getAmount(), 1.25E+3);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.montecarlo.LiborMarketModelMonteCarloMethod

  public void longShortParity() {
    final YieldAndDiscountCurve dsc = CURVES.getCurve(CURVES_NAME[0]);
    final CurrencyAmount pvLongExplicit = METHOD_LMM_CAP.presentValue(CAP_LAST, BUNDLE_LMM);
    final CurrencyAmount pvShortExplicit = METHOD_LMM_CAP.presentValue(CAP_LAST_SHORT, BUNDLE_LMM);
    assertEquals("Cap/floor - LMM - present value - long/short parity", pvLongExplicit.getAmount(), -pvShortExplicit.getAmount(), 1E-2);
    LiborMarketModelMonteCarloMethod methodLmmMc;
    methodLmmMc = new LiborMarketModelMonteCarloMethod(new NormalRandomNumberGenerator(0.0, 1.0, new MersenneTwister()), NB_PATH);
    final CurrencyAmount pvLongMC = methodLmmMc.presentValue(CAP_LAST, CUR, dsc, BUNDLE_LMM);
    methodLmmMc = new LiborMarketModelMonteCarloMethod(new NormalRandomNumberGenerator(0.0, 1.0, new MersenneTwister()), NB_PATH);
    final CurrencyAmount pvShortMC = methodLmmMc.presentValue(CAP_LAST_SHORT, CUR, dsc, BUNDLE_LMM);
    assertEquals("Cap/floor - LMM - present value MC- long/short parity", pvLongMC.getAmount(), -pvShortMC.getAmount(), 1E-2);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.montecarlo.LiborMarketModelMonteCarloMethod

    final CurrencyAmount pvFloorExplicit = METHOD_LMM_CAP.presentValue(FLOOR_LAST, BUNDLE_LMM);
    final double pvFixedExplicit = -SWAP_PAYER.getFirstLeg().getNthPayment(NB_CPN_IBOR - 1).accept(PVC, CURVES);
    final double pvIborExplicit = SWAP_PAYER.getSecondLeg().getNthPayment(NB_CPN_IBOR - 1).accept(PVC, CURVES);
    assertEquals("Cap/floor - LMM - present value Explcit- cap/floor/strike/Ibor parity", pvCapExplicit.getAmount() - pvFloorExplicit.getAmount() + pvFixedExplicit, pvIborExplicit, 1E-2);
    final YieldAndDiscountCurve dsc = CURVES.getCurve(CURVES_NAME[0]);
    LiborMarketModelMonteCarloMethod methodLmmMc;
    methodLmmMc = new LiborMarketModelMonteCarloMethod(new NormalRandomNumberGenerator(0.0, 1.0, new MersenneTwister()), NB_PATH);
    final CurrencyAmount pvCapMC = methodLmmMc.presentValue(CAP_LAST, CUR, dsc, BUNDLE_LMM);
    methodLmmMc = new LiborMarketModelMonteCarloMethod(new NormalRandomNumberGenerator(0.0, 1.0, new MersenneTwister()), NB_PATH);
    final CurrencyAmount pvFloorMC = methodLmmMc.presentValue(FLOOR_LAST, CUR, dsc, BUNDLE_LMM);
    assertEquals("Cap/floor - LMM - present value - cap/floor/strike/Ibor parity", pvCapMC.getAmount() - pvFloorMC.getAmount() + pvFixedExplicit, pvIborExplicit, 1.1E+3);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.montecarlo.LiborMarketModelMonteCarloMethod

  public void performance() {
    long startTime, endTime;
    final int nbTest = 10;

    final YieldAndDiscountCurve dsc = CURVES.getCurve(CURVES_NAME[0]);
    LiborMarketModelMonteCarloMethod methodLmmMc;
    methodLmmMc = new LiborMarketModelMonteCarloMethod(new NormalRandomNumberGenerator(0.0, 1.0, new MersenneTwister()), NB_PATH);
    final double[] pvMC = new double[nbTest];

    startTime = System.currentTimeMillis();
    for (int looptest = 0; looptest < nbTest; looptest++) {
      pvMC[looptest] = methodLmmMc.presentValue(CAP_LAST, CUR, dsc, BUNDLE_LMM).getAmount();
    }
    endTime = System.currentTimeMillis();
    System.out.println(nbTest + " cap/floor LMM Monte Carlo method: " + (endTime - startTime) + " ms");
    // Performance note: LMM Monte Carlo: 15-Sep-11: On Mac Pro 3.2 GHz Quad-Core Intel Xeon: 980 ms for 10 cap (12,500 paths).
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.montecarlo.LiborMarketModelMonteCarloMethod

  @Test
  /**
   * Test the Ratchet present value in the case where the first coupon is fixed. Tested against a previous run number.
   */
  public void presentValueFixed() {
    LiborMarketModelMonteCarloMethod methodMC;
    methodMC = new LiborMarketModelMonteCarloMethod(new NormalRandomNumberGenerator(0.0, 1.0, new MersenneTwister()), NB_PATH);
    // Seed fixed to the DEFAULT_SEED for testing purposes.
    final CurrencyAmount pvMC = methodMC.presentValue(ANNUITY_RATCHET_FIXED, EUR, CURVES.getCurve(CURVES_NAMES[0]), BUNDLE_LMM);
    final double pvMCPreviousRun = 8525698.689;
    assertEquals("Annuity Ratchet Ibor - LMM - Monte Carlo", pvMCPreviousRun, pvMC.getAmount(), 1.0E-2);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.