Package com.opengamma.analytics.financial.model.option.definition

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


    final AmericanVanillaOptionDefinition definition = new AmericanVanillaOptionDefinition(1., NINE_MONTHS, true);
    super.assertInputs(model, definition);
    AmericanVanillaOptionDefinition call = new AmericanVanillaOptionDefinition(STRIKE, TENTH_YEAR, true);
    AmericanVanillaOptionDefinition put = new AmericanVanillaOptionDefinition(STRIKE, TENTH_YEAR, false);
    final VolatilitySurface surface = new VolatilitySurface(ConstantDoublesSurface.from(SIGMA1));
    StandardOptionDataBundle vars = new StandardOptionDataBundle(CURVE, B, surface, SPOT1, DATE);
    assertResult(model.getGreeks(call, vars, GREEK_SET), 0.0205, eps);
    vars = vars.withSpot(SPOT2);
    assertResult(model.getGreeks(call, vars, GREEK_SET), 1.8757, eps);
    vars = vars.withSpot(SPOT3);
    assertResult(model.getGreeks(call, vars, GREEK_SET), 10, eps);
    vars = vars.withVolatilitySurface(new VolatilitySurface(ConstantDoublesSurface.from(SIGMA2))).withSpot(SPOT1);
    assertResult(model.getGreeks(call, vars, GREEK_SET), 0.3151, eps);
    vars = vars.withSpot(SPOT2);
    assertResult(model.getGreeks(call, vars, GREEK_SET), 3.1256, eps);
    vars = vars.withSpot(SPOT3);
    assertResult(model.getGreeks(call, vars, GREEK_SET), 10.3725, eps);
    vars = vars.withVolatilitySurface(new VolatilitySurface(ConstantDoublesSurface.from(SIGMA3))).withSpot(SPOT1);
    assertResult(model.getGreeks(call, vars, GREEK_SET), 0.9479, eps);
    vars = vars.withSpot(SPOT2);
    assertResult(model.getGreeks(call, vars, GREEK_SET), 4.3746, eps);
    vars = vars.withSpot(SPOT3);
    assertResult(model.getGreeks(call, vars, GREEK_SET), 11.1578, eps);

    call = new AmericanVanillaOptionDefinition(STRIKE, SIX_MONTHS, true);
    vars = vars.withVolatilitySurface(new VolatilitySurface(ConstantDoublesSurface.from(SIGMA1))).withSpot(SPOT1);
    assertResult(model.getGreeks(call, vars, GREEK_SET), 0.8099, eps);
    vars = vars.withSpot(SPOT2);
    assertResult(model.getGreeks(call, vars, GREEK_SET), 4.0628, eps);
    vars = vars.withSpot(SPOT3);
    assertResult(model.getGreeks(call, vars, GREEK_SET), 10.7898, eps);
    vars = vars.withVolatilitySurface(new VolatilitySurface(ConstantDoublesSurface.from(SIGMA2))).withSpot(SPOT1);
    assertResult(model.getGreeks(call, vars, GREEK_SET), 2.7180, eps);
    vars = vars.withSpot(SPOT2);
    assertResult(model.getGreeks(call, vars, GREEK_SET), 6.7661, eps);
    vars = vars.withSpot(SPOT3);
    assertResult(model.getGreeks(call, vars, GREEK_SET), 12.9814, eps);
    vars = vars.withVolatilitySurface(new VolatilitySurface(ConstantDoublesSurface.from(SIGMA3))).withSpot(SPOT1);
    assertResult(model.getGreeks(call, vars, GREEK_SET), 4.9665, eps);
    vars = vars.withSpot(SPOT2);
    assertResult(model.getGreeks(call, vars, GREEK_SET), 9.4608, eps);
    vars = vars.withSpot(SPOT3);
    assertResult(model.getGreeks(call, vars, GREEK_SET), 15.5137, eps);

    vars = vars.withVolatilitySurface(new VolatilitySurface(ConstantDoublesSurface.from(SIGMA1))).withSpot(SPOT1);
    assertResult(model.getGreeks(put, vars, GREEK_SET), 10.0000, eps);
    vars = vars.withSpot(SPOT2);
    assertResult(model.getGreeks(put, vars, GREEK_SET), 1.8757, eps);
    vars = vars.withSpot(SPOT3);
    assertResult(model.getGreeks(put, vars, GREEK_SET), 0.0408, eps);
    vars = vars.withVolatilitySurface(new VolatilitySurface(ConstantDoublesSurface.from(SIGMA2))).withSpot(SPOT1);
    assertResult(model.getGreeks(put, vars, GREEK_SET), 10.2280, eps);
    vars = vars.withSpot(SPOT2);
    assertResult(model.getGreeks(put, vars, GREEK_SET), 3.1256, eps);
    vars = vars.withSpot(SPOT3);
    assertResult(model.getGreeks(put, vars, GREEK_SET), 0.4552, eps);
    vars = vars.withVolatilitySurface(new VolatilitySurface(ConstantDoublesSurface.from(SIGMA3))).withSpot(SPOT1);
    assertResult(model.getGreeks(put, vars, GREEK_SET), 10.8663, eps);
    vars = vars.withSpot(SPOT2);
    assertResult(model.getGreeks(put, vars, GREEK_SET), 4.3746, eps);
    vars = vars.withSpot(SPOT3);
    assertResult(model.getGreeks(put, vars, GREEK_SET), 1.2383, eps);

    put = new AmericanVanillaOptionDefinition(STRIKE, SIX_MONTHS, false);
    vars = vars.withVolatilitySurface(new VolatilitySurface(ConstantDoublesSurface.from(SIGMA1))).withSpot(SPOT1);
    assertResult(model.getGreeks(put, vars, GREEK_SET), 10.54, eps);
    vars = vars.withSpot(SPOT2);
    assertResult(model.getGreeks(put, vars, GREEK_SET), 4.0628, eps);
    vars = vars.withSpot(SPOT3);
    assertResult(model.getGreeks(put, vars, GREEK_SET), 1.0689, eps);
    vars = vars.withVolatilitySurface(new VolatilitySurface(ConstantDoublesSurface.from(SIGMA2))).withSpot(SPOT1);
    assertResult(model.getGreeks(put, vars, GREEK_SET), 12.4097, eps);
    vars = vars.withSpot(SPOT2);
    assertResult(model.getGreeks(put, vars, GREEK_SET), 6.7661, eps);
    vars = vars.withSpot(SPOT3);
    assertResult(model.getGreeks(put, vars, GREEK_SET), 3.2932, eps);
    vars = vars.withVolatilitySurface(new VolatilitySurface(ConstantDoublesSurface.from(SIGMA3))).withSpot(SPOT1);
    assertResult(model.getGreeks(put, vars, GREEK_SET), 14.6445, eps);
    vars = vars.withSpot(SPOT2);
    assertResult(model.getGreeks(put, vars, GREEK_SET), 9.4608, eps);
    vars = vars.withSpot(SPOT3);
    assertResult(model.getGreeks(put, vars, GREEK_SET), 5.8374, eps);
  }
View Full Code Here


    MODEL.getPricingFunction(OPTION).evaluate((StandardOptionDataBundle) null);
  }

  @Test
  public void testZeroVol() {
    StandardOptionDataBundle data = DATA.withVolatilitySurface(new VolatilitySurface(ConstantDoublesSurface.from(1e-15))).withSpot(LOWER - 1);
    assertEquals(MODEL.getPricingFunction(OPTION).evaluate(data), 0, 0);
    data = data.withSpot(UPPER + 1);
    assertEquals(MODEL.getPricingFunction(OPTION).evaluate(data), 0, 0);
  }
View Full Code Here

    assertPriceEquals(definition, 0.5, 0.0532);
    assertPriceEquals(definition, 0.6, 0.0691);
  }

  private void assertPriceEquals(final LogOptionDefinition definition, final double sigma, final double price) {
    final StandardOptionDataBundle bundle = getBundle(sigma);
    final GreekResultCollection actual = MODEL.getGreeks(definition, bundle, REQUIRED_GREEKS);
    assertEquals(actual.get(Greek.FAIR_PRICE), price, EPS);
  }
View Full Code Here

    final GreekResultCollection actual = MODEL.getGreeks(definition, bundle, REQUIRED_GREEKS);
    assertEquals(actual.get(Greek.FAIR_PRICE), price, EPS);
  }

  private StandardOptionDataBundle getBundle(final double sigma) {
    return new StandardOptionDataBundle(CURVE, B, new VolatilitySurface(ConstantDoublesSurface.from(sigma)), SPOT, DATE);
  }
View Full Code Here

  }

  @Test
  public void testZeroVol() {
    final double delta = 20;
    final StandardOptionDataBundle data = DATA.withVolatilitySurface(new VolatilitySurface(ConstantDoublesSurface.from(0)));
    Function1D<StandardOptionDataBundle, Double> f = MODEL.getPricingFunction(PUT);
    final double df = Math.exp(-R * T);
    assertEquals(f.evaluate(data.withSpot(STRIKE - delta)), df * PAYMENT, EPS);
    assertEquals(f.evaluate(data.withSpot(STRIKE + delta)), 0, EPS);
    final CashOrNothingOptionDefinition call = new CashOrNothingOptionDefinition(STRIKE, EXPIRY, true, PAYMENT);
    f = MODEL.getPricingFunction(call);
    assertEquals(f.evaluate(data.withSpot(STRIKE + delta)), df * PAYMENT, EPS);
    assertEquals(f.evaluate(data.withSpot(STRIKE - delta)), 0, EPS);
  }
View Full Code Here

    MODEL.getPricingFunction(new GapOptionDefinition(STRIKE, EXPIRY, true, PAYOFF_STRIKE)).evaluate((StandardOptionDataBundle) null);
  }

  @Test
  public void testAgainstBSM() {
    final StandardOptionDataBundle data = DATA;
    final Function1D<StandardOptionDataBundle, Double> call = MODEL.getPricingFunction(new GapOptionDefinition(STRIKE, EXPIRY, true, STRIKE));
    final Function1D<StandardOptionDataBundle, Double> put = MODEL.getPricingFunction(new GapOptionDefinition(STRIKE, EXPIRY, false, STRIKE));
    final Function1D<StandardOptionDataBundle, Double> bsmCall = BSM.getPricingFunction(new EuropeanVanillaOptionDefinition(STRIKE, EXPIRY, true));
    final Function1D<StandardOptionDataBundle, Double> bsmPut = BSM.getPricingFunction(new EuropeanVanillaOptionDefinition(STRIKE, EXPIRY, false));
    assertEquals(call.evaluate(data), bsmCall.evaluate(data), EPS);
View Full Code Here

    MODEL.getPricingFunction(PUT).evaluate((StandardOptionDataBundle) null);
  }

  @Test
  public void testZeroVol() {
    StandardOptionDataBundle data = DATA.withVolatilitySurface(new VolatilitySurface(ConstantDoublesSurface.from(0)));
    final double df = Math.exp(T * (B - R));
    assertEquals(MODEL.getPricingFunction(CALL).evaluate(data), df * SPOT, EPS);
    assertEquals(MODEL.getPricingFunction(PUT).evaluate(data), 0, 0);
    data = data.withSpot(60);
    assertEquals(MODEL.getPricingFunction(CALL).evaluate(data), 0, 0);
    assertEquals(MODEL.getPricingFunction(PUT).evaluate(data), df * 60, EPS);
  }
View Full Code Here

    assertPriceEquals(definition, 0.2, 1061.2120);
    assertPriceEquals(definition, 0.3, 3745.1853);
  }

  private void assertPriceEquals(final PoweredOptionDefinition poweredDefinition, final EuropeanVanillaOptionDefinition vanillaDefinition, final double sigma) {
    final StandardOptionDataBundle bundle = getBundle(sigma);
    final GreekResultCollection actual = POWERED_MODEL.getGreeks(poweredDefinition, bundle, REQUIRED_GREEKS);
    final GreekResultCollection expected = BSM.getGreeks(vanillaDefinition, bundle, REQUIRED_GREEKS);
    assertEquals(expected.get(Greek.FAIR_PRICE), actual.get(Greek.FAIR_PRICE), SMALL_EPS);
  }
View Full Code Here

    final GreekResultCollection expected = BSM.getGreeks(vanillaDefinition, bundle, REQUIRED_GREEKS);
    assertEquals(expected.get(Greek.FAIR_PRICE), actual.get(Greek.FAIR_PRICE), SMALL_EPS);
  }

  private void assertPriceEquals(final PoweredOptionDefinition poweredDefinition, final double sigma, final double price) {
    final StandardOptionDataBundle bundle = getBundle(sigma);
    final GreekResultCollection actual = POWERED_MODEL.getGreeks(poweredDefinition, bundle, REQUIRED_GREEKS);
    assertEquals(price, actual.get(Greek.FAIR_PRICE), BIG_EPS * price);
  }
View Full Code Here

    final GreekResultCollection actual = POWERED_MODEL.getGreeks(poweredDefinition, bundle, REQUIRED_GREEKS);
    assertEquals(price, actual.get(Greek.FAIR_PRICE), BIG_EPS * price);
  }

  private StandardOptionDataBundle getBundle(final double sigma) {
    return new StandardOptionDataBundle(CURVE, B, new VolatilitySurface(ConstantDoublesSurface.from(sigma)), SPOT, DATE);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.model.option.definition.StandardOptionDataBundle

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.