Package com.opengamma.analytics.financial.montecarlo

Examples of com.opengamma.analytics.financial.montecarlo.HullWhiteMonteCarloMethod.presentValue()


    Validate.notNull(curves);
    if (!(curves instanceof HullWhiteOneFactorPiecewiseConstantDataBundle)) {
      throw new UnsupportedOperationException("The PresentValueHullWhiteMonteCarloCalculator visitor visitSwaptionPhysicalFixedIbor requires a HullWhiteOneFactorPiecewiseConstantDataBundle as data.");
    }
    final HullWhiteMonteCarloMethod methodMC = new HullWhiteMonteCarloMethod(new NormalRandomNumberGenerator(0.0, 1.0, new MersenneTwister()), _nbPath);
    final CurrencyAmount pvMC = methodMC
        .presentValue(swaption, swaption.getCurrency(), swaption.getUnderlyingSwap().getFirstLeg().getDiscountCurve(), (HullWhiteOneFactorPiecewiseConstantDataBundle) curves);
    return pvMC.getAmount();
  }

  @Override
View Full Code Here


    Validate.notNull(curves);
    if (!(curves instanceof HullWhiteOneFactorPiecewiseConstantDataBundle)) {
      throw new UnsupportedOperationException("The PresentValueHullWhiteMonteCarloCalculator visitor visitSwaptionPhysicalFixedIbor requires a HullWhiteOneFactorPiecewiseConstantDataBundle as data.");
    }
    final HullWhiteMonteCarloMethod methodMC = new HullWhiteMonteCarloMethod(new NormalRandomNumberGenerator(0.0, 1.0, new MersenneTwister()), _nbPath);
    final CurrencyAmount pvMC = methodMC.presentValue(annuity, annuity.getCurrency(), annuity.getDiscountCurve(), (HullWhiteOneFactorPiecewiseConstantDataBundle) curves);
    return pvMC.getAmount();
  }

}
View Full Code Here

  public void monteCarlo() {
    HullWhiteMonteCarloMethod methodMC;
    methodMC = new HullWhiteMonteCarloMethod(new NormalRandomNumberGenerator(0.0, 1.0, new MersenneTwister()), 10 * NB_PATH);
    // Seed fixed to the DEFAULT_SEED for testing purposes.
    final CurrencyAmount pvExplicit = METHOD_HW.presentValue(CAP_LONG, BUNDLE_HW);
    final CurrencyAmount pvMC = methodMC.presentValue(CAP_LONG, CUR, CURVES_NAME[0], BUNDLE_HW);
    assertEquals("Cap/floor - Hull-White - Monte Carlo", pvExplicit.getAmount(), pvMC.getAmount(), 4.0E+2);
    final double pvMCPreviousRun = 150060.593;
    assertEquals("Swaption physical - Hull-White - Monte Carlo", pvMCPreviousRun, pvMC.getAmount(), 1.0E-2);
    methodMC = new HullWhiteMonteCarloMethod(new NormalRandomNumberGenerator(0.0, 1.0, new MersenneTwister()), 10 * NB_PATH);
    final CurrencyAmount pvShortMC = methodMC.presentValue(CAP_SHORT, CUR, CURVES_NAME[0], BUNDLE_HW);
View Full Code Here

    final CurrencyAmount pvMC = methodMC.presentValue(CAP_LONG, CUR, CURVES_NAME[0], BUNDLE_HW);
    assertEquals("Cap/floor - Hull-White - Monte Carlo", pvExplicit.getAmount(), pvMC.getAmount(), 4.0E+2);
    final double pvMCPreviousRun = 150060.593;
    assertEquals("Swaption physical - Hull-White - Monte Carlo", pvMCPreviousRun, pvMC.getAmount(), 1.0E-2);
    methodMC = new HullWhiteMonteCarloMethod(new NormalRandomNumberGenerator(0.0, 1.0, new MersenneTwister()), 10 * NB_PATH);
    final CurrencyAmount pvShortMC = methodMC.presentValue(CAP_SHORT, CUR, CURVES_NAME[0], BUNDLE_HW);
    assertEquals("Swaption physical - Hull-White - Monte Carlo", -pvMC.getAmount(), pvShortMC.getAmount(), 1.0E-2);
  }

  @Test(enabled = false)
  /**
 
View Full Code Here

    final int nbTest = 10;
    final double[] pv = new double[nbTest];
    final double[] pvDiff = new double[nbTest];
    startTime = System.currentTimeMillis();
    for (int looptest = 0; looptest < nbTest; looptest++) {
      pv[looptest] = methodMC.presentValue(CAP_LONG, CUR, CURVES_NAME[0], BUNDLE_HW).getAmount();
      pvDiff[looptest] = pv[looptest] - pvExplicit.getAmount();
    }
    endTime = System.currentTimeMillis();
    System.out.println(nbTest + " pv cap/floor Hull-White MC method (" + nbPath + " paths): " + (endTime - startTime) + " ms");
    // Performance note: price: 12-Jun-12: On Mac Pro 3.2 GHz Quad-Core Intel Xeon: 2400 ms for 10 cap with 1,000,000 paths.
View Full Code Here

    // Calibration
    calibrationEngine.calibrate(curves);
    final HullWhiteOneFactorPiecewiseConstantDataBundle hwBundle = new HullWhiteOneFactorPiecewiseConstantDataBundle(hwParameters, curves);
    // Pricing
    final HullWhiteMonteCarloMethod methodMC = new HullWhiteMonteCarloMethod(new NormalRandomNumberGenerator(0.0, 1.0, new MersenneTwister()), DEFAULT_NB_PATH);
    final CurrencyAmount pvMC = methodMC.presentValue(swaption, swaption.getCurrency(), swaption.getUnderlyingSwap().getFirstLeg().getDiscountCurve(), hwBundle);
    return pvMC.getAmount();
  }

  @Override
  public Double visitAnnuityCouponIborRatchet(final AnnuityCouponIborRatchet annuity, final YieldCurveBundle curves) {
View Full Code Here

    // Calibration
    calibrationEngine.calibrate(curves);
    final HullWhiteOneFactorPiecewiseConstantDataBundle hwBundle = new HullWhiteOneFactorPiecewiseConstantDataBundle(hwParameters, curves);
    // Pricing
    final HullWhiteMonteCarloMethod methodMC = new HullWhiteMonteCarloMethod(new NormalRandomNumberGenerator(0.0, 1.0, new MersenneTwister()), DEFAULT_NB_PATH);
    final CurrencyAmount pvMC = methodMC.presentValue(annuity, annuity.getCurrency(), annuity.getDiscountCurve(), hwBundle);
    return pvMC.getAmount();
  }

}
View Full Code Here

    final int nbPath = 12500;
    HullWhiteMonteCarloMethod methodMC;
    methodMC = new HullWhiteMonteCarloMethod(new NormalRandomNumberGenerator(0.0, 1.0, new MersenneTwister()), nbPath);
    // Seed fixed to the DEFAULT_SEED for testing purposes.
    final CurrencyAmount pvPayerLongExplicit = METHOD_HW.presentValue(SWAPTION_PAYER_LONG, BUNDLE_HW);
    final CurrencyAmount pvPayerLongMC = methodMC.presentValue(SWAPTION_PAYER_LONG, CUR, FUNDING_CURVE_NAME, BUNDLE_HW);
    assertEquals("Swaption physical - Hull-White - Monte Carlo", pvPayerLongExplicit.getAmount(), pvPayerLongMC.getAmount(), 1.0E+4);
    final double pvMCPreviousRun = 5137844.655;
    assertEquals("Swaption physical - Hull-White - Monte Carlo", pvMCPreviousRun, pvPayerLongMC.getAmount(), 1.0E-2);
    methodMC = new HullWhiteMonteCarloMethod(new NormalRandomNumberGenerator(0.0, 1.0, new MersenneTwister()), nbPath);
    final CurrencyAmount pvPayerShortMC = methodMC.presentValue(SWAPTION_PAYER_SHORT, CUR, FUNDING_CURVE_NAME, BUNDLE_HW);
View Full Code Here

    final CurrencyAmount pvPayerLongMC = methodMC.presentValue(SWAPTION_PAYER_LONG, CUR, FUNDING_CURVE_NAME, BUNDLE_HW);
    assertEquals("Swaption physical - Hull-White - Monte Carlo", pvPayerLongExplicit.getAmount(), pvPayerLongMC.getAmount(), 1.0E+4);
    final double pvMCPreviousRun = 5137844.655;
    assertEquals("Swaption physical - Hull-White - Monte Carlo", pvMCPreviousRun, pvPayerLongMC.getAmount(), 1.0E-2);
    methodMC = new HullWhiteMonteCarloMethod(new NormalRandomNumberGenerator(0.0, 1.0, new MersenneTwister()), nbPath);
    final CurrencyAmount pvPayerShortMC = methodMC.presentValue(SWAPTION_PAYER_SHORT, CUR, FUNDING_CURVE_NAME, BUNDLE_HW);
    assertEquals("Swaption physical - Hull-White - Monte Carlo", -pvPayerLongMC.getAmount(), pvPayerShortMC.getAmount(), 1.0E-2);
    final CurrencyAmount pvReceiverLongMC = methodMC.presentValue(SWAPTION_RECEIVER_LONG, CUR, FUNDING_CURVE_NAME, BUNDLE_HW);
    final double pvSwap = SWAP_RECEIVER.accept(PVC, CURVES);
    assertEquals("Swaption physical - Hull-White - Monte Carlo - payer/receiver/swap parity", pvReceiverLongMC.getAmount() + pvPayerShortMC.getAmount(), pvSwap, 1.0E+5);
  }
View Full Code Here

    final double pvMCPreviousRun = 5137844.655;
    assertEquals("Swaption physical - Hull-White - Monte Carlo", pvMCPreviousRun, pvPayerLongMC.getAmount(), 1.0E-2);
    methodMC = new HullWhiteMonteCarloMethod(new NormalRandomNumberGenerator(0.0, 1.0, new MersenneTwister()), nbPath);
    final CurrencyAmount pvPayerShortMC = methodMC.presentValue(SWAPTION_PAYER_SHORT, CUR, FUNDING_CURVE_NAME, BUNDLE_HW);
    assertEquals("Swaption physical - Hull-White - Monte Carlo", -pvPayerLongMC.getAmount(), pvPayerShortMC.getAmount(), 1.0E-2);
    final CurrencyAmount pvReceiverLongMC = methodMC.presentValue(SWAPTION_RECEIVER_LONG, CUR, FUNDING_CURVE_NAME, BUNDLE_HW);
    final double pvSwap = SWAP_RECEIVER.accept(PVC, CURVES);
    assertEquals("Swaption physical - Hull-White - Monte Carlo - payer/receiver/swap parity", pvReceiverLongMC.getAmount() + pvPayerShortMC.getAmount(), pvSwap, 1.0E+5);
  }

  @Test
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.