Examples of BlackVolatilitySurfaceStrike


Examples of com.opengamma.analytics.financial.model.volatility.surface.BlackVolatilitySurfaceStrike

        }
        final double vol2 = BlackFormulaRepository.impliedVolatility(price, f, k, t, isCall);
        return vol2;
      }
    };
    return new BlackVolatilitySurfaceStrike(FunctionalDoublesSurface.from(impVol));
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.surface.BlackVolatilitySurfaceStrike

    ArgumentChecker.notNull(dividends, "dividends");
    ArgumentChecker.notNull(marketVols, "market volatilities");

    final PureImpliedVolatilitySurface piv = getPureImpliedVolFromMarket(spot, discountCurve, dividends, marketVols);
    final EquityDividendsCurvesBundle divCurves = new EquityDividendsCurvesBundle(spot, discountCurve, dividends);
    final BlackVolatilitySurfaceStrike iv = VolatilitySurfaceConverter.convertImpliedVolSurface(piv, divCurves);

    final double eps = 1e-5;
    final int index = swap.correctForDividends() ? 0 : 1;
    final double t = swap.getTimeToSettlement();

    //up
    final BlackVolatilitySurfaceStrike ivUp = new BlackVolatilitySurfaceStrike(flooredShiftSurface(iv.getSurface(), eps));
    final double up = Math.sqrt(VAR_SWAP_CALCULATOR.expectedVariance(spot, discountCurve, dividends, t, ivUp)[index] / t);
    //down
    final BlackVolatilitySurfaceStrike ivDown = new BlackVolatilitySurfaceStrike(flooredShiftSurface(iv.getSurface(), -eps));
    final double down = Math.sqrt(VAR_SWAP_CALCULATOR.expectedVariance(spot, discountCurve, dividends, t, ivDown)[index] / t);
    final double vega = (up - down) / 2 / eps;
    return vega;
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.surface.BlackVolatilitySurfaceStrike

        final EuropeanVanillaOption option = new EuropeanVanillaOption(k, t, true);
        return SABR.getVolatility(option, fwd, data);
      }
    };

    return new BlackVolatilitySurfaceStrike(FunctionalDoublesSurface.from(sabrSurface));
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.surface.BlackVolatilitySurfaceStrike

    return new BlackVolatilitySurfaceStrike(FunctionalDoublesSurface.from(sabrSurface));
  }

  private static LocalVolatilitySurfaceStrike getSABRLocalVolSurface(final double beta, final ForwardCurve forwardCurve) {
    final DupireLocalVolatilityCalculator cal = new DupireLocalVolatilityCalculator();
    final BlackVolatilitySurfaceStrike impVol = getSABRImpliedVolSurface(beta, forwardCurve);
    return cal.getLocalVolatility(impVol, forwardCurve);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.surface.BlackVolatilitySurfaceStrike

    return cal.getLocalVolatility(impVol, forwardCurve);
  }

  private static PriceSurface getSABRPriceSurface(final double beta, final ForwardCurve forwardCurve, final YieldAndDiscountCurve discountCurve) {

    final BlackVolatilitySurfaceStrike impVol = getSABRImpliedVolSurface(beta, forwardCurve);
    final Function<Double, Double> priceSurface = new Function<Double, Double>() {
      @Override
      public Double evaluate(final Double... x) {
        final double t = x[0];
        final double k = x[1];
        final double fwd = forwardCurve.getForward(t);
        final double vol = impVol.getVolatility(t, k);
        return discountCurve.getDiscountFactor(t) * BlackFormulaRepository.price(fwd, k, t, vol, true);
      }
    };
    return new PriceSurface(FunctionalDoublesSurface.from(priceSurface));
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.surface.BlackVolatilitySurfaceStrike

        final double price = w * BlackFormulaRepository.price(fwd, k, t, sigma1, isCall) + (1 - w) * BlackFormulaRepository.price(fwd, k, t, sigma2, isCall);
        return BlackFormulaRepository.impliedVolatility(price, fwd, k, t, isCall);
      }
    };

    final BlackVolatilitySurfaceStrike surfaceStrike = new BlackVolatilitySurfaceStrike(FunctionalDoublesSurface.from(surf));

    final double[] res = STATIC_REPLICATION.expectedVariance(SPOT, DISCOUNT_CURVE, dividends, EXPIRY, surfaceStrike);
    final double rv = res[0] / EXPIRY;
    final double expected = w * sigma1 * sigma1 + (1 - w) * sigma2 * sigma2;
    assertEquals(expected, rv, 2e-6); //TODO this should be better
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.surface.BlackVolatilitySurfaceStrike

      }
    }

    //calculate by static replication using actual prices of put and call prices  (converted from pure prices)
    //NOTE, this surface is converted from the (smooth, flat) pure implied vol surface, and will have the correct discontinuities at cash dividend dates
    final BlackVolatilitySurfaceStrike impVol = VolatilitySurfaceConverter.convertImpliedVolSurface(PURE_IMPLIED_VOL_FLAT, divCurves);
    res = STATIC_REPLICATION.expectedVariance(SPOT, DISCOUNT_CURVE, dividends, EXPIRY, impVol);
    final double srRV1 = res[0] / EXPIRY;
    final double srRV2 = res[1] / EXPIRY;
    if (PRINT) {
      System.out.format("Static replication (real price):  RV1 = %1$.8f RV2 = %2$.8f%n", srRV1, srRV2);
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.surface.BlackVolatilitySurfaceStrike

  private void testNumerics(final AffineDividends dividends, final MultiHorizonMixedLogNormalModelData data, final double defaultTol) {

    final ForwardCurve fc = new ForwardCurve(1.0);
    final LocalVolatilitySurfaceStrike lv = MixedLogNormalVolatilitySurface.getLocalVolatilitySurface(fc, data);
    final PureLocalVolatilitySurface plv = new PureLocalVolatilitySurface(lv.getSurface());
    final BlackVolatilitySurfaceStrike iv = MixedLogNormalVolatilitySurface.getImpliedVolatilitySurface(fc, data);
    final PureImpliedVolatilitySurface piv = new PureImpliedVolatilitySurface(iv.getSurface());
    final double[] weights = data.getWeights();
    final double[] mus = data.getMus();
    final double[] sigmas = data.getVolatilities();
    final double m = weights.length;
    final int n = dividends.getNumberOfDividends();
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.surface.BlackVolatilitySurfaceStrike

    }

    //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
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.surface.BlackVolatilitySurfaceStrike

  /**
   * Test ConstantDoublesSurface strike surface at 1 and 10 years
   */
  @Test
  public void testConstantDoublesStrikeSurface() {
    final BlackVolatilitySurfaceStrike constVolSurf = new BlackVolatilitySurfaceStrike(ConstantDoublesSurface.from(TEST_VOL));
    final double testVar = PRICER.expectedVariance(swap1, new StaticReplicationDataBundle(constVolSurf, DISCOUNT, FORWARD_CURVE));
    final double testVar2 = PRICER.expectedVariance(swap10, new StaticReplicationDataBundle(constVolSurf, DISCOUNT, FORWARD_CURVE));
    final double targetVar = TEST_VOL * TEST_VOL;
    assertEquals(targetVar, testVar, TEST_TOL);
    assertEquals(targetVar, testVar2, TEST_TOL);
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.