Package com.opengamma.analytics.financial.model.option.pricing.analytic.formula

Examples of com.opengamma.analytics.financial.model.option.pricing.analytic.formula.BlackPriceFunction


    _rand = new MersenneTwister64(seed);
  }

  public double price(final double forward, final double df, final double strike, final double timeToExiry, final double[] sigmas) {
    final EuropeanVanillaOption option = new EuropeanVanillaOption(strike, timeToExiry, true);
    final BlackPriceFunction func = new BlackPriceFunction();
    final Function1D<BlackFunctionData, Double> priceFunc = func.getPriceFunction(option);
    double sum = 0;
    for (final double sigma : sigmas) {
      final BlackFunctionData data = new BlackFunctionData(forward, df, sigma);
      sum += priceFunc.evaluate(data);
    }
View Full Code Here


    final int nStrikes = strike.length;
    Validate.isTrue(nTime == df.length);
    Validate.isTrue(nTime == expiries.length);
    Validate.isTrue(nTime == sigmas.length);

    final BlackPriceFunction func = new BlackPriceFunction();
    final double[][] price = new double[nTime][nStrikes];

    double t, k;
    for (int j = 0; j < nTime; j++) {
      t = expiries[j];
      final double[] tSigmas = sigmas[j];
      for (int i = 0; i < nStrikes; i++) {
        k = strike[i];
        final EuropeanVanillaOption option = new EuropeanVanillaOption(k, t, true);
        final Function1D<BlackFunctionData, Double> priceFunc = func.getPriceFunction(option);
        double sum = 0;
        for (final double sigma : tSigmas) {
          final BlackFunctionData data = new BlackFunctionData(forwards[j], df[j], sigma);
          sum += priceFunc.evaluate(data);
        }
View Full Code Here

   * @return The price
   */
  public double price(final double forward, final double df, final double strike) {

    final EuropeanVanillaOption option = new EuropeanVanillaOption(strike, _t, true);
    final BlackPriceFunction func = new BlackPriceFunction();
    final Function1D<BlackFunctionData, Double> priceFunc = func.getPriceFunction(option);
    double sum = 0;

    for (int i = 0; i < _weights.length; i++) {
      final BlackFunctionData data = new BlackFunctionData(forward, df, _vols[i]);
      sum += _weights[i] * priceFunc.evaluate(data);
 
View Full Code Here

    final SABRFormulaData sabrPoint = new SABRFormulaData(alpha, beta, rho, nu);
    final EuropeanVanillaOption option = new EuropeanVanillaOption(strike, cmsCapFloor.getFixingTime(), cmsCapFloor.isCap());
    final Function1D<SABRFormulaData, double[]> sabrFunctionAdjoint = sabrParameter.getSabrFunction().getVolatilityAdjointFunction(option, forward);
    final double[] volA = sabrFunctionAdjoint.evaluate(sabrPoint);
    final BlackFunctionData dataBlack = new BlackFunctionData(forward, 1.0, volA[0]);
    final BlackPriceFunction blackFunction = new BlackPriceFunction();
    final double[] bsA = blackFunction.getPriceAdjoint(option, dataBlack);

    final double[] kpkpp = integrant.kpkpp(strike);
    double firstPart;
    double thirdPart;
    if (cmsCapFloor.isCap()) {
View Full Code Here

    final MultipleCurrencyAmount pvMethod = METHOD_BLACK.presentValue(SWAPTION_LONG_REC, BLACK_MULTICURVES);
    final double forward = SWAPTION_LONG_REC.getUnderlyingSwap().accept(PRC, MULTICURVES);
    final double pvbp = METHOD_SWAP.getAnnuityCash(SWAPTION_LONG_REC.getUnderlyingSwap(), forward);
    final double discountFactorSettle = MULTICURVES.getDiscountFactor(SWAPTION_LONG_REC.getCurrency(), SWAPTION_LONG_REC.getSettlementTime());
    final double volatility = BLACK.getVolatility(SWAPTION_LONG_REC.getTimeToExpiry(), SWAPTION_LONG_REC.getMaturityTime());
    final BlackPriceFunction blackFunction = new BlackPriceFunction();
    final BlackFunctionData dataBlack = new BlackFunctionData(forward, pvbp * discountFactorSettle, volatility);
    final Function1D<BlackFunctionData, Double> func = blackFunction.getPriceFunction(SWAPTION_LONG_REC);
    final double pvExpected = func.evaluate(dataBlack);
    assertEquals("Swaption Black method: present value", 1, pvMethod.size());
    final CurrencyAmount ca = pvMethod.getCurrencyAmounts()[0];
    assertEquals("Swaption Black method: present value", SWAPTION_LONG_REC.getCurrency(), ca.getCurrency());
    assertEquals("Swaption Black method: present value", pvExpected, ca.getAmount(), TOLERANCE_PRICE);
View Full Code Here

    final double pvbp = METHOD_SWAP_SPREAD.presentValueBasisPoint(SWAP_SPREAD_EUR1Y3M, EUR1YEURIBOR3M.getFixedLegDayCount(), MULTICURVES);
    final double forward = METHOD_SWAP_SPREAD.forwardSwapSpreadModified(SWAP_SPREAD_EUR1Y3M, pvbp, MULTICURVES);
    final double strike = METHOD_SWAP_SPREAD.couponEquivalentSpreadModified(SWAP_SPREAD_EUR1Y3M, pvbp, MULTICURVES);
    final double volatility = BLACK.getVolatility(SWAPTION_SPREAD_EUR1Y3M.getTimeToExpiry(), SWAPTION_SPREAD_EUR1Y3M.getMaturityTime());
    final EuropeanVanillaOption option = new EuropeanVanillaOption(strike, SWAPTION_SPREAD_EUR1Y3M.getTimeToExpiry(), SWAPTION_SPREAD_EUR1Y3M.isCall());
    final BlackPriceFunction blackFunction = new BlackPriceFunction();
    final BlackFunctionData dataBlack = new BlackFunctionData(forward, pvbp, volatility);
    final Function1D<BlackFunctionData, Double> func = blackFunction.getPriceFunction(option);
    final double pvExpected = func.evaluate(dataBlack) * (IS_LONG ? 1.0 : -1.0);
    assertEquals("SwaptionPhysicalFixedIborSpreadBlackMethod: presentValue", pvExpected, pvComputed.getAmount(EUR), TOLERANCE_PV);
  }
View Full Code Here

  public void presentValue() {
    final MultipleCurrencyAmount pvMethod = METHOD_BLACK.presentValue(SWAPTION_LONG_REC, BLACK_MULTICURVES);
    final double forward = SWAPTION_LONG_REC.getUnderlyingSwap().accept(PRDC, MULTICURVES);
    final double pvbp = METHOD_SWAP.presentValueBasisPoint(SWAPTION_LONG_REC.getUnderlyingSwap(), MULTICURVES);
    final double volatility = BLACK.getVolatility(SWAPTION_LONG_REC.getTimeToExpiry(), SWAPTION_LONG_REC.getMaturityTime());
    final BlackPriceFunction blackFunction = new BlackPriceFunction();
    final BlackFunctionData dataBlack = new BlackFunctionData(forward, pvbp, volatility);
    final Function1D<BlackFunctionData, Double> func = blackFunction.getPriceFunction(SWAPTION_LONG_REC);
    final double pvExpected = func.evaluate(dataBlack);
    assertEquals("Swaption Black method: present value", pvExpected, pvMethod.getAmount(EUR), TOLERANCE_PV);
  }
View Full Code Here

    final double vol = Math.sqrt(VOL_A * VOL_A + VOL_B * VOL_B - 2 * RHO * VOL_A * VOL_B);
    final double forward = SPOT_A / SPOT_B;
    final double strike = 1.0;
    final BlackFunctionData data = new BlackFunctionData(forward, SPOT_B, vol);
    final EuropeanVanillaOption option = new EuropeanVanillaOption(strike, T, true);
    final BlackPriceFunction pricer = new BlackPriceFunction();
    final Function1D<BlackFunctionData, Double> func = pricer.getPriceFunction(option);
    final double price = func.evaluate(data);

    final double pdfPrice = res[(int) (SPOT_A * spotASteps / (A_UPPER.getLevel() - A_LOWER.getLevel()))][(int) (SPOT_B * spotBSteps / (B_UPPER.getLevel() - B_LOWER.getLevel()))];

    // System.out.println(price+"\t"+pdfPrice);
View Full Code Here

  /**
   * Tests the strikes computations.
   */
  public void strike() {
    double[] strike = SMILE.getStrike(FORWARD);
    BlackPriceFunction function = new BlackPriceFunction();
    double[] volatility = SMILE.getVolatility();
    int nbDelta = DELTA.length;
    for (int loopdelta = 0; loopdelta < nbDelta; loopdelta++) {
      BlackFunctionData dataPut = new BlackFunctionData(FORWARD, 1.0, volatility[loopdelta]);
      EuropeanVanillaOption optionPut = new EuropeanVanillaOption(strike[loopdelta], TIME_TO_EXPIRY, false);
      double[] dPut = function.getPriceAdjoint(optionPut, dataPut);
      assertEquals("Strike: Put " + loopdelta, dPut[1], -DELTA[loopdelta], 1.0E-8);
      BlackFunctionData dataCall = new BlackFunctionData(FORWARD, 1.0, volatility[2 * nbDelta - loopdelta]);
      EuropeanVanillaOption optionCall = new EuropeanVanillaOption(strike[2 * nbDelta - loopdelta], TIME_TO_EXPIRY, true);
      double[] dCall = function.getPriceAdjoint(optionCall, dataCall);
      assertEquals("Strike: Call " + loopdelta, dCall[1], DELTA[loopdelta], 1.0E-8);
    }
    BlackFunctionData data = new BlackFunctionData(FORWARD, 1.0, volatility[nbDelta]);
    EuropeanVanillaOption optionPut = new EuropeanVanillaOption(strike[nbDelta], TIME_TO_EXPIRY, false);
    double[] dPut = function.getPriceAdjoint(optionPut, data);
    EuropeanVanillaOption optionCall = new EuropeanVanillaOption(strike[nbDelta], TIME_TO_EXPIRY, true);
    double[] dCall = function.getPriceAdjoint(optionCall, data);
    assertEquals("Strike: ATM", dCall[1] + dPut[1], 0.0, 1.0E-8);
  }
View Full Code Here

  public void presentValue() {
    final CurrencyAmount pvMethod = METHOD_BLACK.presentValue(SWAPTION_LONG_REC, CURVES_BLACK);
    final double forward = SWAPTION_LONG_REC.getUnderlyingSwap().accept(PRC, CURVES);
    final double pvbp = METHOD_SWAP.presentValueBasisPoint(SWAPTION_LONG_REC.getUnderlyingSwap(), CURVES);
    final double volatility = BLACK.getVolatility(SWAPTION_LONG_REC.getTimeToExpiry(), SWAPTION_LONG_REC.getMaturityTime());
    final BlackPriceFunction blackFunction = new BlackPriceFunction();
    final BlackFunctionData dataBlack = new BlackFunctionData(forward, pvbp, volatility);
    final Function1D<BlackFunctionData, Double> func = blackFunction.getPriceFunction(SWAPTION_LONG_REC);
    final double pvExpected = func.evaluate(dataBlack);
    assertEquals("Swaption Black method: present value", SWAPTION_LONG_REC.getCurrency(), pvMethod.getCurrency());
    assertEquals("Swaption Black method: present value", pvExpected, pvMethod.getAmount(), TOLERANCE_PV);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.model.option.pricing.analytic.formula.BlackPriceFunction

Copyright © 2018 www.massapicom. 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.