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

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


    final double forwardModified = PRDC.visitFixedCouponSwap(swaption.getUnderlyingSwap(), dayCountModification, sabrData.getMulticurveProvider());
    final double strikeModified = METHOD_SWAP.couponEquivalent(swaption.getUnderlyingSwap(), pvbpModified, sabrData.getMulticurveProvider());
    final double maturity = swaption.getMaturityTime();
    final PresentValueSABRSensitivityDataBundle sensi = new PresentValueSABRSensitivityDataBundle();
    final DoublesPair expiryMaturity = new DoublesPair(swaption.getTimeToExpiry(), maturity);
    final EuropeanVanillaOption option = new EuropeanVanillaOption(strikeModified, swaption.getTimeToExpiry(), swaption.isCall());
    // Implementation note: option required to pass the strike (in case the swap has non-constant coupon).
    final BlackPriceFunction blackFunction = new BlackPriceFunction();
    final double[] volatilityAdjoint = sabrData.getSABRParameter().getVolatilityAdjoint(swaption.getTimeToExpiry(), maturity, strikeModified, forwardModified);
    final BlackFunctionData dataBlack = new BlackFunctionData(forwardModified, 1.0, volatilityAdjoint[0]);
    final double[] bsAdjoint = blackFunction.getPriceAdjoint(option, dataBlack);
View Full Code Here


    final double pvbpModified = METHOD_SWAP.presentValueBasisPoint(swaption.getUnderlyingSwap(), dayCountModification, sabrData.getMulticurveProvider());
    final double forwardModified = PRDC.visitFixedCouponSwap(swaption.getUnderlyingSwap(), dayCountModification, sabrData.getMulticurveProvider());
    final double strikeModified = METHOD_SWAP.couponEquivalent(swaption.getUnderlyingSwap(), pvbpModified, sabrData.getMulticurveProvider());
    final double maturity = swaption.getMaturityTime();
    // TODO: A better notion of maturity may be required (using period?)
    final EuropeanVanillaOption option = new EuropeanVanillaOption(strikeModified, swaption.getTimeToExpiry(), swaption.isCall());
    // Implementation note: option required to pass the strike (in case the swap has non-constant coupon).
    final BlackPriceFunction blackFunction = new BlackPriceFunction();
    final double[] volatilityAdjoint = sabrData.getSABRParameter().getVolatilityAdjoint(swaption.getTimeToExpiry(), maturity, strikeModified, forwardModified);
    final BlackFunctionData dataBlack = new BlackFunctionData(forwardModified, 1.0, volatilityAdjoint[0]);
    final Function1D<BlackFunctionData, Double> func = blackFunction.getPriceFunction(option);
View Full Code Here

      price = strikeNprice[i][1];
      k = strikeNprice[i][0];

      double impVol = 0;
      try {
        final EuropeanVanillaOption o = new EuropeanVanillaOption(k, T, true);
        impVol = BLACK_IMPLIED_VOL.getImpliedVolatility(DATA, o, price);
      } catch (final Exception e) {
      }
      assertEquals(SIGMA, impVol, 1e-5);
    }
View Full Code Here

    for (int i = 0; i < 5; i++) {
      final double alpha = -1.6 + i * 0.5;
      for (int j = 0; j < 1; j++) {
        isCall = (j == 0);

        final EuropeanVanillaOption option = new EuropeanVanillaOption(FORWARD, T, isCall);
        final double[][] strikeNprice = PRICER.price(FORWARD, DF, T, isCall, CEF, FORWARD, FORWARD, 1, 0.3, alpha, tol);
        assertEquals(FORWARD, strikeNprice[0][0], 1e-9);
        assertEquals(SIGMA, BLACK_IMPLIED_VOL.getImpliedVolatility(DATA, option, strikeNprice[0][1]), 1e-7);
      }
    }
View Full Code Here

    final double[] k = new double[n];
    final double[] vol = new double[n];
    for (int i = 0; i < n; i++) {
      k[i] = strikeNPrice[i][0];
      vol[i] = BLACK_IMPLIED_VOL.getImpliedVolatility(new BlackFunctionData(FORWARD, DF, 0.0), new EuropeanVanillaOption(k[i], t, isCall), strikeNPrice[i][1]);
    }

    final Interpolator1DDataBundle dataBundle = INTERPOLATOR.getDataBundleFromSortedArrays(k, vol);
    final double[][] strikeNPrice2 = PRICER.price(FORWARD, DF, t, isCall, heston, 0.7 * FORWARD, 1.5 * FORWARD, nStrikes, 0.2, 0.75, 1e-8);
    final int m = strikeNPrice2.length;
    for (int i = 0; i < m; i++) {
      final double strike = strikeNPrice2[i][0];
      final double sigma = BLACK_IMPLIED_VOL.getImpliedVolatility(new BlackFunctionData(FORWARD, DF, 0.0), new EuropeanVanillaOption(strike, t, isCall), strikeNPrice2[i][1]);
      assertEquals(sigma, INTERPOLATOR.interpolate(dataBundle, strike), 1e-5);
    }

  }
View Full Code Here

    final MixedBivariateLogNormalModelVolatility volObjZ1 = new MixedBivariateLogNormalModelVolatility(wghts, sigsX,
        sigsY, rpfsX, rpfsY, rhs);
    final MixedBivariateLogNormalModelVolatility volObjZ2 = new MixedBivariateLogNormalModelVolatility(wghts, sigsX,
        sigsY, rhs);
    final EuropeanVanillaOption option = new EuropeanVanillaOption(k, timeToExpiry, true);

    assertEquals(volObjZ1.getImpliedVolatilityZ(option, forwardZ), Math.pow(0.5, 0.5), EPS);
    assertEquals(volObjZ2.getImpliedVolatilityZ(option, forwardZ), Math.pow(0.5, 0.5), EPS);
    assertEquals(volObjZ1.getSigmasZ()[0], Math.pow(0.5, 0.5), EPS);
    assertEquals(volObjZ1.getSigmasZ()[1], Math.pow(0.5, 0.5), EPS);
View Full Code Here

    final double integral = integrator.integrate(f, 0.0, 1000.0) / Math.PI;

    final double price = DF * FORWARD * integral;
    double impVol = 0;
    try {
      final EuropeanVanillaOption option = new EuropeanVanillaOption(FORWARD, T, true);
      final BlackFunctionData data = new BlackFunctionData(FORWARD, DF, 0);
      impVol = BLACK_IMPLIED_VOL.getImpliedVolatility(data, option, price);
    } catch (final Exception e) {
    }
    assertEquals(SIGMA, impVol, 1e-5);
View Full Code Here

    final double timeToExpiry = 0.6;
    final MixedLogNormalVolatilityFunction volfunc = MixedLogNormalVolatilityFunction.getInstance();

    for (int i = 0; i < 101; i++) {
      final double k = forwardZ * (0.5 + 1. * i / 100.);
      final EuropeanVanillaOption option = new EuropeanVanillaOption(k, timeToExpiry, true);
      final double vol1 = objZ.getImpliedVolatilityZ(option, forwardZ);
      final double vol2 = volfunc.getVolatility(option, forwardX, objX);
      final double vol3 = volfunc.getVolatility(option, forwardY, objY);
      System.out.println(k + "\t" + vol1 + "\t" + vol2 + "\t" + vol3);
    }
View Full Code Here

    for (int j = 0; j < 51; j++) {
      final double time = 0.5 * (0.5 + 2. * j / 100.);
      for (int i = 0; i < 51; i++) {
        final double k = forwardZ * (0.5 + 1. * i / 100.);
        final EuropeanVanillaOption option = new EuropeanVanillaOption(k, time, true);
        final double vol1 = objZ.getImpliedVolatilityZ(option, forwardZ);
        System.out.println(k + "\t" + time + "\t" + vol1);
      }
    }
  }
View Full Code Here

  public void testCGMY() {
    final FourierPricer pricer = new FourierPricer();
    final BlackFunctionData data = new BlackFunctionData(FORWARD, DF, 0);
    for (int i = 0; i < 21; i++) {
      final double k = 0.01 + 0.14 * i / 20.0;
      final EuropeanVanillaOption option = new EuropeanVanillaOption(k, T, true);
      final double price = pricer.price(data, option, CGMY_CE, -0.5, 1e-6);
      @SuppressWarnings("unused")
      final double impVol = BLACK_IMPLIED_VOL.getImpliedVolatility(data, option, price);
      //System.out.println(k + "\t" + impVol);
    }
View Full Code Here

TOP

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

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.