Examples of LocalVolatilitySurfaceStrike


Examples of com.opengamma.analytics.financial.model.volatility.local.LocalVolatilitySurfaceStrike

      System.out.format("Analytic:  RV1 = %1$.8f RV2 = %2$.8f%n", expDivCorr, expDivNoCorr);
    }

    //convert the pure (implied and local)
    final EquityDividendsCurvesBundle divCurves = new EquityDividendsCurvesBundle(SPOT, DISCOUNT_CURVE, dividends);
    final LocalVolatilitySurfaceStrike localVol = VolatilitySurfaceConverter.convertLocalVolSurface(plv, divCurves);
    final BlackVolatilitySurfaceStrike impVol = VolatilitySurfaceConverter.convertImpliedVolSurface(pImpVol, divCurves);
    final double fT = divCurves.getF(EXPIRY);

    //run Monte Carlo (simulating the PURE stock process)
    double[] res = MC_CALCULATOR_PURE.solve(SPOT, DISCOUNT_CURVE, dividends, EXPIRY, plv, N_SIMS);
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.local.LocalVolatilitySurfaceStrike

  public void fokkerPlankTest() {
    final DupireLocalVolatilityCalculator cal = new DupireLocalVolatilityCalculator(1e-4);

    final BlackVolatilitySurfaceStrike volSurface = new BlackVolatilitySurfaceStrike(FunctionalDoublesSurface.from(SABR_VOL_FUNCTION));

    final LocalVolatilitySurfaceStrike localVol = cal.getLocalVolatility(volSurface, new ForwardCurve(SPOT, RATE));

    //    final ZZConvectionDiffusionPDEDataBundle db1 = LocalVolDensity.getConvectionDiffusionPDEDataBundle(FORWARD_CURVE, localVol);
    //    final ExtendedConvectionDiffusionPDEDataBundle db2 = LocalVolDensity.getExtendedConvectionDiffusionPDEDataBundle(FORWARD_CURVE, localVol);

    final int tNodes = 50;
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.local.LocalVolatilitySurfaceStrike

  @Test(enabled = false)
  public void localVolTest() {
    final DupireLocalVolatilityCalculator cal = new DupireLocalVolatilityCalculator();

    final BlackVolatilitySurfaceStrike volSurface = new BlackVolatilitySurfaceStrike(FunctionalDoublesSurface.from(SABR_VOL_FUNCTION));
    final LocalVolatilitySurfaceStrike localVol = cal.getLocalVolatility(volSurface, new ForwardCurve(SPOT, RATE));

    PDEUtilityTools.printSurface("localVolTest", localVol.getSurface(), 0, 5.0, SPOT / 4.0, SPOT * 4.0);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.local.LocalVolatilitySurfaceStrike

        final double rt = Math.exp(tau * R);
        return sigma * Math.pow(rt * s, beta - 1.0);
      }
    };

    final LocalVolatilitySurfaceStrike volSurf = new LocalVolatilitySurfaceStrike(FunctionalDoublesSurface.from(vol));
    final EuropeanVanillaOption option = new EuropeanVanillaOption(k, T, isCall);
    final CEVFunctionData data = new CEVFunctionData(fwd, df, sigma, beta);

    final Function1D<CEVFunctionData, Double> priceFunc = cev.getPriceFunction(option);
    final double cevPrice = priceFunc.evaluate(data);
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.local.LocalVolatilitySurfaceStrike

    //    double[] w = new double[] {0.99, 0.01, 0.0000};
    //    double[] sigma = new double[] {0.3, 0.5, 0.8};
    //  double[] mu = new double[] {0.0, 0.0, -0.0};
    final MultiHorizonMixedLogNormalModelData data = new MultiHorizonMixedLogNormalModelData(w, sigma, mu);
    final PriceSurface priceSurf = MixedLogNormalVolatilitySurface.getPriceSurface(FWD_CURVE, DIS_CURVE, data);
    final LocalVolatilitySurfaceStrike locVol = MixedLogNormalVolatilitySurface.getLocalVolatilitySurface(FWD_CURVE, data);

    final double k = 14.0;
    final boolean isCall = true;

    final int tNodes = 50;
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.local.LocalVolatilitySurfaceStrike

    double[] mu = new double[] {0.0, 0.3, -0.5 };
    MultiHorizonMixedLogNormalModelData data = new MultiHorizonMixedLogNormalModelData(w, sigma, mu);
    BlackVolatilitySurfaceStrike ivs = MixedLogNormalVolatilitySurface.getImpliedVolatilitySurface(fc, data);
    PDEUtilityTools.printSurface("imp vol", ivs.getSurface(), 0.01, 2.0, spot * 0.1, spot * 3.0);

    LocalVolatilitySurfaceStrike lvs = MixedLogNormalVolatilitySurface.getLocalVolatilitySurface(fc, data);
    PDEUtilityTools.printSurface("local vol", lvs.getSurface(), 0.00, 2.0, spot * 0.1, spot * 3.0);

    DupireLocalVolatilityCalculator cal = new DupireLocalVolatilityCalculator();
    LocalVolatilitySurfaceStrike lv2 = cal.getLocalVolatility(ivs, fc);
    //    PDEUtilityTools.printSurface("local vo2l", lv2.getSurface(), 0.01, 2.0, spot * 0.3, spot * 3.0);

    System.out.println("lv: " + lvs.getVolatility(2.0, 1.7 * spot));
    System.out.println("lv2: " + lv2.getVolatility(2.0, 1.7 * spot));

    EquityVarianceSwapStaticReplication vsPricer = new EquityVarianceSwapStaticReplication();
    double[] res = vsPricer.expectedVariance(spot, discountCurve, AffineDividends.noDividends(), t, ivs);
    System.out.println(Math.sqrt(res[0] / t));

View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.local.LocalVolatilitySurfaceStrike

    final double vol = 0.3;
    double[] w = new double[] {0.6, 0.4 };
    double[] sigma = new double[] {vol, vol };
    MultiHorizonMixedLogNormalModelData data = new MultiHorizonMixedLogNormalModelData(w, sigma);
    BlackVolatilitySurfaceStrike ivs = MixedLogNormalVolatilitySurface.getImpliedVolatilitySurface(fc, data);
    LocalVolatilitySurfaceStrike lvs = MixedLogNormalVolatilitySurface.getLocalVolatilitySurface(fc, data);
    for (int i = 0; i < 100; i++) {
      double t = 5.0 * RANDOM.nextDouble();
      //strikes in range +- 8-sigma
      double a = 16 * (RANDOM.nextDouble() - 0.5);
      double k = spot * Math.exp((r - vol * vol / 2) * t + Math.sqrt(t) * vol * a);
      double iv = ivs.getVolatility(t, k);
      double lv = lvs.getVolatility(t, k);
      assertEquals("implied volatility t=" + t + ", k=" + k, vol, iv, 1e-14);
      assertEquals("local volatilityt=" + t + ", k=" + k, vol, lv, 1e-14);
    }
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.local.LocalVolatilitySurfaceStrike

    final double vol = 0.3;
    double[] w = new double[] {0.8, 0.2 };
    double[] sigma = new double[] {0.2, 0.7 };
    MultiHorizonMixedLogNormalModelData data = new MultiHorizonMixedLogNormalModelData(w, sigma);
    BlackVolatilitySurfaceStrike ivs = MixedLogNormalVolatilitySurface.getImpliedVolatilitySurface(fc, data);
    LocalVolatilitySurfaceStrike lvs = MixedLogNormalVolatilitySurface.getLocalVolatilitySurface(fc, data);
    LocalVolatilitySurfaceStrike lvs2 = dupire.getLocalVolatility(ivs, fc);

    for (int i = 0; i < 100; i++) {
      double t = 5.0 * RANDOM.nextDouble();
      //strikes in range +- 8-sigma
      double a = 16 * (RANDOM.nextDouble() - 0.5);
      double k = spot * Math.exp((r - vol * vol / 2) * t + Math.sqrt(t) * vol * a);
      double lv = lvs.getVolatility(t, k);
      double lv2 = lvs2.getVolatility(t, k);
      assertEquals("Local volatility t=" + t + ", k=" + k, lv, lv2, 1e-3); //loss a lot of accuracy going via Dupire formula (since this used finite difference on the implied vol surface)
    }
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.local.LocalVolatilitySurfaceStrike

    double[] sigma = new double[] {0.2, 0.7 };
    double[] mu = new double[] {0.1, -0.1 };

    MultiHorizonMixedLogNormalModelData data = new MultiHorizonMixedLogNormalModelData(w, sigma, mu);
    BlackVolatilitySurfaceStrike ivs = MixedLogNormalVolatilitySurface.getImpliedVolatilitySurface(fc, data);
    LocalVolatilitySurfaceStrike lvs = MixedLogNormalVolatilitySurface.getLocalVolatilitySurface(fc, data);
    LocalVolatilitySurfaceStrike lvs2 = dupire.getLocalVolatility(ivs, fc);

    for (int i = 0; i < 100; i++) {
      double t = 5.0 * RANDOM.nextDouble();
      //strikes in range +- 8-sigma
      double a = 16 * (RANDOM.nextDouble() - 0.5);
      double k = spot * Math.exp((r - vol * vol / 2) * t + Math.sqrt(t) * vol * a);
      double lv = lvs.getVolatility(t, k);
      double lv2 = lvs2.getVolatility(t, k);
      assertEquals("Local volatility t=" + t + ", k=" + k, lv, lv2, 1e-3); //loss a lot of accuracy going via Dupire formula (since this used finite difference on the implied vol surface)
    }

    //lvs.getVolatility(3.86, 0.177);

View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.local.LocalVolatilitySurfaceStrike

    final double t = 1.0 / 365.;
    final double rootT = Math.sqrt(t);
    final double fwd = fwdCurve.getForward(t);

    BlackVolatilitySurfaceStrike ivs = MixedLogNormalVolatilitySurface.getImpliedVolatilitySurface(fwdCurve, mlnData);
    LocalVolatilitySurfaceStrike lvs = MixedLogNormalVolatilitySurface.getLocalVolatilitySurface(fwdCurve, mlnData);
    LocalVolatilitySurfaceMoneyness lvsm = LocalVolatilitySurfaceConverter.toMoneynessSurface(lvs, fwdCurve);

    //    PDEUtilityTools.printSurface("imp vol", ivs.getSurface(), 0, t, 0.9, 1.1);
    //    DupireLocalVolatilityCalculator dupire = new DupireLocalVolatilityCalculator();
    //    LocalVolatilitySurfaceMoneyness dlv = dupire.getLocalVolatility(BlackVolatilitySurfaceConverter.toMoneynessSurface(ivs, fwdCurve));
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.