Examples of OptionDefinition


Examples of com.opengamma.analytics.financial.model.option.definition.OptionDefinition

    ArgumentChecker.notEmpty(optionData, "option data");
    Validate.notNull(data, "data");
    if (optionData.size() > 1) {
      s_logger.warn("Have more than one option: only using the first");
    }
    final OptionDefinition option = optionData.keySet().iterator().next();
    final double k = option.getStrike();
    final double t = option.getTimeToExpiry(data.getDate());
    final double sigma = data.getVolatility(t, k);
    final double beta = data.getElasticity();
    final double forward = data.getSpot();
    final double f = 0.5 * (forward + k);
    final double beta1 = 1 - beta;
View Full Code Here

Examples of com.opengamma.analytics.financial.model.option.definition.OptionDefinition

        final double r = data.getInterestRate(t);
        final double b = data.getCostOfCarry();
        final double skew = data.getAnnualizedSkew();
        final double kurtosis = data.getAnnualizedFisherKurtosis();
        final double sigmaT = sigma * Math.sqrt(t);
        OptionDefinition callDefinition = definition;
        if (!definition.isCall()) {
          callDefinition = new EuropeanVanillaOptionDefinition(callDefinition.getStrike(), callDefinition.getExpiry(), true);
        }
        final Function1D<StandardOptionDataBundle, Double> bsm = BSM.getPricingFunction(callDefinition);
        final double bsmCall = bsm.evaluate(data);
        final double w = getW(sigma, t, skew, kurtosis);
        final double d = getD(s, k, sigma, t, b, w, sigmaT);
View Full Code Here

Examples of com.opengamma.analytics.financial.model.option.definition.OptionDefinition

      @SuppressWarnings("synthetic-access")
      @Override
      public Double evaluate(final StandardOptionDataBundle data) {
        Validate.notNull(data, "data");
        final double s = data.getSpot();
        final OptionDefinition underlying = definition.getUnderlyingOption();
        final double k1 = definition.getStrike();
        final double k2 = underlying.getStrike();
        final ZonedDateTime date = data.getDate();
        final double t1 = definition.getTimeToExpiry(date);
        final double sigma = data.getVolatility(t1, k1);
        final double r = data.getInterestRate(t1);
        final double b = data.getCostOfCarry();
        final OptionDefinition callDefinition = underlying.isCall() ? underlying : new EuropeanVanillaOptionDefinition(k2, underlying.getExpiry(), true);
        final GreekResultCollection result = BSM.getGreeks(callDefinition, data, REQUIRED_GREEKS);
        final double callBSM = result.get(Greek.FAIR_PRICE);
        final double callDelta = result.get(Greek.DELTA);
        final double underlyingSigma = sigma * Math.abs(callDelta) * s / callBSM;
        final double d1 = getD1(callBSM, k1, t1, underlyingSigma, b);
View Full Code Here

Examples of com.opengamma.analytics.financial.model.option.definition.OptionDefinition

      @SuppressWarnings("synthetic-access")
      @Override
      public Double evaluate(final StandardOptionDataBundle data) {
        Validate.notNull(data, "data");
        final double s = data.getSpot();
        final OptionDefinition underlying = definition.getUnderlyingOption();
        final double k1 = definition.getStrike();
        final double k2 = underlying.getStrike();
        final ZonedDateTime date = data.getDate();
        final double t1 = definition.getTimeToExpiry(date);
        final double t2 = definition.getUnderlyingOption().getTimeToExpiry(date);
        final double deltaT = t2 - t1;
        final double sigma = data.getVolatility(t1, k1); //REVIEW emcleod 20-7-10 This will work with a flat volatility surface but otherwise will give odd results
        final double r = data.getInterestRate(t1);
        final double b = data.getCostOfCarry();
        final double criticalValue = getCriticalValue(new EuropeanVanillaOptionDefinition(k2, new Expiry(DateUtils.getDateOffsetWithYearFraction(date, deltaT)), underlying.isCall()), data, k1);
        final double d1 = getD1(s, criticalValue, t1, sigma, b);
        final double d2 = getD2(d1, sigma, t1);
        final double d3 = getD1(s, k2, t2, sigma, b);
        final double d4 = getD2(d3, sigma, t2);
        if (definition.isCall()) {
          final double rho = Math.sqrt(t1 / t2);
          if (underlying.isCall()) {
            return s * Math.exp(t2 * (b - r)) * BIVARIATE.getCDF(new double[] {d3, d1, rho}) - k2 * Math.exp(-r * t2) * BIVARIATE.getCDF(new double[] {d4, d2, rho}) - k1 * Math.exp(-r * t1)
                * NORMAL.getCDF(d2);
          }
          return k2 * Math.exp(-r * t2) * BIVARIATE.getCDF(new double[] {-d4, -d2, rho}) - s * Math.exp(t2 * (b - r)) * BIVARIATE.getCDF(new double[] {-d3, -d1, rho}) - k1 * Math.exp(-r * t1)
              * NORMAL.getCDF(-d2);
        }
        final double rho = -Math.sqrt(t1 / t2);
        if (underlying.isCall()) {
          return k2 * Math.exp(-r * t2) * BIVARIATE.getCDF(new double[] {d4, -d2, rho}) - s * Math.exp(t2 * (b - r)) * BIVARIATE.getCDF(new double[] {d3, -d1, rho}) + k1 * Math.exp(-r * t1)
              * NORMAL.getCDF(-d2);
        }
        return s * Math.exp(t2 * (b - r)) * BIVARIATE.getCDF(new double[] {-d3, d1, rho}) - k2 * Math.exp(-r * t2) * BIVARIATE.getCDF(new double[] {-d4, d2, rho}) + k1 * Math.exp(-r * t1)
            * NORMAL.getCDF(d2);
 
View Full Code Here

Examples of com.opengamma.analytics.financial.model.option.definition.OptionDefinition

        final double lambda = data.getHalfLife();
        final double sigmaLR = data.getLongRunVolatility();
        final double volOfSigma = data.getVolatilityOfVolatility();
        final double rho = data.getCorrelation();
        final StandardOptionDataBundle bsmData = new StandardOptionDataBundle(data);
        final OptionDefinition call = definition.isCall() ? definition : new EuropeanVanillaOptionDefinition(k, definition.getExpiry(), true);
        final double beta = -Math.log(2) / lambda;
        final double alpha = -beta * sigmaLR * sigmaLR;
        final double delta = beta * t;
        final double eDelta = Math.exp(delta);
        final boolean betaIsZero = CompareUtils.closeEquals(beta, 0, ZERO);
View Full Code Here

Examples of com.opengamma.analytics.financial.model.option.definition.OptionDefinition

        final double sigma = data.getVolatility(t, k);
        final double r = data.getInterestRate(t);
        final double b = data.getCostOfCarry();
        final double skew = data.getAnnualizedSkew();
        final double kurtosis = data.getAnnualizedPearsonKurtosis();
        final OptionDefinition callDefinition = definition.isCall() ? definition : new EuropeanVanillaOptionDefinition(k, definition.getExpiry(), true);
        final Function1D<StandardOptionDataBundle, Double> bsm = BSM.getPricingFunction(callDefinition);
        final double bsmCall = bsm.evaluate(data);
        final double d2 = getD2(getD1(s, k, t, sigma, b), sigma, t);
        final double sigmaT = sigma * Math.sqrt(t);
        final double a = getA(d2, k, sigmaT);
View Full Code Here

Examples of com.opengamma.analytics.financial.model.option.definition.OptionDefinition

  public void test() {
    assertEquals(MODEL.getSurface(OPTION, DATA).getVolatility(PAIR), 0.3454, EPS);
    SABRDataBundle data1 = DATA.withRho(-0.75).withBeta(0.999);
    SABRDataBundle data2 = DATA.withRho(0).withBeta(0.999);
    SABRDataBundle data3 = DATA.withRho(0.5).withBeta(0.999);
    OptionDefinition option = new EuropeanVanillaOptionDefinition(70, EXPIRY, false);
    data1 = CALIBRATION.calibrate(option, data1);
    data2 = CALIBRATION.calibrate(option, data2);
    data3 = CALIBRATION.calibrate(option, data3);
    assertEquals(MODEL.getSurface(option, data1).getVolatility(PAIR), 0.3668, EPS);
    assertEquals(MODEL.getSurface(option, data2).getVolatility(PAIR), 0.3165, EPS);
View Full Code Here

Examples of com.opengamma.analytics.financial.model.option.definition.OptionDefinition

  }

  @Test
  public void test() {
    final double eps = 1e-4;
    OptionDefinition option = new EuropeanVanillaOptionDefinition(90, EXPIRY, true);
    ConstantElasticityOfVarianceModelDataBundle data = DATA.withVolatilitySurface(new VolatilitySurface(ConstantDoublesSurface.from(0)));
    VolatilitySurface blackEquivalent = MODEL.getSurface(Collections.<OptionDefinition, Double> singletonMap(option, 0.), data);
    assertEquals(BSM.getPricingFunction(option).evaluate(data.withVolatilitySurface(blackEquivalent)), BSM.getPricingFunction(option).evaluate(data), 0);
    data = DATA.withVolatilitySurface(new VolatilitySurface(ConstantDoublesSurface.from(0.5)));
    blackEquivalent = MODEL.getSurface(Collections.<OptionDefinition, Double> singletonMap(option, 0.), data);
View Full Code Here

Examples of com.opengamma.analytics.financial.model.option.definition.OptionDefinition

  @Test
  public void testFlatSurface() {
    final Map<OptionDefinition, Double> prices = new HashMap<>();
    final double sigma = 0.3;
    OptionDefinition definition;
    final StandardOptionDataBundle data = new StandardOptionDataBundle(CURVE, B, new VolatilitySurface(ConstantDoublesSurface.from(sigma)), SPOT, DATE);
    try {
      MODEL.getSurface(prices, data);
      Assert.fail();
    } catch (final IllegalArgumentException e) {
View Full Code Here

Examples of com.opengamma.analytics.financial.model.option.definition.OptionDefinition

  }

  @Test
  public void testUnifomlyVaryingSurface() {
    final Map<OptionDefinition, Double> prices = new HashMap<>();
    OptionDefinition definition;
    StandardOptionDataBundle data = new StandardOptionDataBundle(CURVE, B, null, SPOT, DATE);
    final double diff = 0.09;
    final double startSigma = 0.18;
    final double[] sigma = new double[] {startSigma, startSigma + diff, startSigma + 2 * diff, startSigma + 3 * diff};
    for (int i = 0; i < sigma.length; i++) {
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.