Package com.opengamma.analytics.financial.equity.variance.pricing

Examples of com.opengamma.analytics.financial.equity.variance.pricing.EquityDividendsCurvesBundle


  /**
   * Tests the Monte Carlo (which required a local volatility surface (strike)) against a static replication (which requires a pure implied volatility surface)
   * @param dividends
   */
  private void testNumericsForFlatPureVol(final AffineDividends dividends) {
    final EquityDividendsCurvesBundle divCurves = new EquityDividendsCurvesBundle(SPOT, DISCOUNT_CURVE, dividends);
    final LocalVolatilitySurfaceStrike localVol = VolatilitySurfaceConverter.convertLocalVolSurface(PURE_LOCAL_VOL_FLAT, divCurves);

    //get the analytic values of the expected variance if there are no cash dividends
    boolean canPriceAnalytic = true;
    for (int i = 0; i < dividends.getNumberOfDividends(); i++) {
      if (dividends.getAlpha(i) > 0.0) {
        canPriceAnalytic = false;
        break;
      }
    }
    double anVar1 = 0;
    double anVar2 = 0;
    if (canPriceAnalytic) {
      int index = 0;
      double anCorr = 0;
      final int n = dividends.getNumberOfDividends();
      while (n > 0 && index < n && dividends.getTau(index) < EXPIRY) {
        anCorr += FunctionUtils.square(Math.log(1 - dividends.getBeta(index)));
        index++;
      }
      anVar1 = PURE_VOL * PURE_VOL;
      anVar2 = anVar1 + anCorr / EXPIRY;
      if (PRINT) {
        System.out.format("Analytic:  RV1 = %1$.8f RV2 = %2$.8f%n", anVar1, anVar2);
      }
    }

    final double fT = divCurves.getF(EXPIRY);

    //run Monte Carlo (simulating the actual stock process)
    double[] res = MC_CALCULATOR.solve(SPOT, DISCOUNT_CURVE, dividends, EXPIRY, localVol, N_SIMS);
    final double mcST = res[0]; //The expected stock price at expiry
    final double mcSDST = Math.sqrt(res[3]); //The Standard Deviation of the expected stock price at expiry
View Full Code Here


    if (PRINT && isAnalytic) {
      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);
    final double mcpST = res[0]; //The expected stock price at expiry
    final double mcpSDST = Math.sqrt(res[3]); //The Standard Deviation of the expected stock price at expiry
View Full Code Here

  private static SmileSurfaceDataBundle getMarketVols(final double spot, final double[] expiries, final double[][] strikes, final YieldAndDiscountCurve discountCurve,
      final AffineDividends dividends, final PureImpliedVolatilitySurface surf) {
    final int nExp = expiries.length;
    final double[] f = new double[nExp];
    final double[][] vols = new double[nExp][];
    final EquityDividendsCurvesBundle divCurves = new EquityDividendsCurvesBundle(spot, discountCurve, dividends);
    for (int i = 0; i < nExp; i++) {
      final int n = strikes[i].length;
      vols[i] = new double[n];
      final double t = expiries[i];
      f[i] = divCurves.getF(t);
      final double d = divCurves.getD(t);
      for (int j = 0; j < n; j++) {
        final double x = (strikes[i][j] - d) / (f[i] - d);
        final boolean isCall = x >= 1.0;
        final double pVol = surf.getVolatility(t, x);
        final double p = (f[i] - d) * BlackFormulaRepository.price(1.0, x, t, pVol, isCall);
View Full Code Here

  private static SmileSurfaceDataBundle getMarketVols(final double spot, final double[] expiries, final double[][] strikes, final YieldAndDiscountCurve discountCurve,
      final AffineDividends dividends, final PureImpliedVolatilitySurface surf) {
    final int nExp = expiries.length;
    final double[] f = new double[nExp];
    final double[][] vols = new double[nExp][];
    final EquityDividendsCurvesBundle divCurves = new EquityDividendsCurvesBundle(spot, discountCurve, dividends);
    for (int i = 0; i < nExp; i++) {
      final int n = strikes[i].length;
      vols[i] = new double[n];
      final double t = expiries[i];
      f[i] = divCurves.getF(t);
      final double d = divCurves.getD(t);
      for (int j = 0; j < n; j++) {
        final double x = (strikes[i][j] - d) / (f[i] - d);
        final boolean isCall = x >= 1.0;
        final double pVol = surf.getVolatility(t, x);
        final double p = (f[i] - d) * BlackFormulaRepository.price(1.0, x, t, pVol, isCall);
View Full Code Here

      sum2 += w[i] * t * (mu[i] - sigma[i] * sigma[i] / 2);
    }
    double temp = Math.sqrt(2 * (Math.log(sum1) - sum2) / t);
    System.out.println("expected: " + temp);

    PureLocalVolatilitySurface plv = VolatilitySurfaceConverter.convertLocalVolSurface(lv2, new EquityDividendsCurvesBundle(spot, discountCurve, AffineDividends.noDividends()));
    EquityVarianceSwapBackwardsPurePDE backCal = new EquityVarianceSwapBackwardsPurePDE();
    res = backCal.expectedVariance(spot, discountCurve, AffineDividends.noDividends(), t, plv);
    System.out.println(Math.sqrt(res[0] / t));

    double vol = lvs.getVolatility(0.0, 25.0);
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.equity.variance.pricing.EquityDividendsCurvesBundle

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.