Examples of VolatilitySurface


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

  }

  @Test
  public void test() {
    ProductOptionDefinition option = new ProductOptionDefinition(15000, EXPIRY1, true);
    StandardTwoAssetOptionDataBundle data = new StandardTwoAssetOptionDataBundle(R, B1, B2, new VolatilitySurface(ConstantDoublesSurface.from(0.2)), new VolatilitySurface(
        ConstantDoublesSurface.from(0.3)), S1, S2, -0.5, DATE);
    assertEquals(MODEL.getPricingFunction(option).evaluate(data), 0.0028, EPS);
    data = data.withFirstVolatilitySurface(new VolatilitySurface(ConstantDoublesSurface.from(0.3))).withCorrelation(0);
    assertEquals(MODEL.getPricingFunction(option).evaluate(data), 2.4026, EPS);
    option = new ProductOptionDefinition(15000, EXPIRY2, true);
    assertEquals(MODEL.getPricingFunction(option).evaluate(data), 266.1594, EPS);
  }
View Full Code Here

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

  }

  @Test
  public void testEuropeanCallTree() {
    final ZonedDateTime date = DateUtils.getUTCDate(2009, 1, 1);
    final StandardOptionDataBundle data = new StandardOptionDataBundle(YieldCurve.from(ConstantDoublesCurve.from(0.06)), 0., new VolatilitySurface(ConstantDoublesSurface.from(0.)), 100., date);
    final OptionDefinition option = new EuropeanVanillaOptionDefinition(100, new Expiry(DateUtils.getDateOffsetWithYearFraction(date, 1)), true);
    final Function1D<StandardOptionDataBundle, RecombiningBinomialTree<DoublesPair>> f = BINOMIAL_THREE_STEPS.getTreeGeneratingFunction(option);
    final DoublesPair[][] result = f.evaluate(data).getNodes();
    final DoublesPair[][] expected = new DoublesPair[4][4];
    expected[0][0] = DoublesPair.of(100., 10.1457);
View Full Code Here

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

  }

  @Test
  public void testAmericanPutTree() {
    final ZonedDateTime date = DateUtils.getUTCDate(2009, 1, 1);
    final StandardOptionDataBundle data = new StandardOptionDataBundle(YieldCurve.from(ConstantDoublesCurve.from(0.06)), 0., new VolatilitySurface(ConstantDoublesSurface.from(0.)), 100., date);
    final OptionDefinition option = new AmericanVanillaOptionDefinition(100, new Expiry(DateUtils.getDateOffsetWithYearFraction(date, 1)), false);
    final Function1D<StandardOptionDataBundle, RecombiningBinomialTree<DoublesPair>> f = BINOMIAL_THREE_STEPS.getTreeGeneratingFunction(option);
    final DoublesPair[][] result = f.evaluate(data).getNodes();
    final DoublesPair[][] expected = new DoublesPair[4][4];
    expected[0][0] = DoublesPair.of(100., 4.6546);
View Full Code Here

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

  }

  @Test
  public void test() {
    double strike = SPOT;
    final StandardOptionDataBundle data = DATA.withVolatilitySurface(new VolatilitySurface(ConstantDoublesSurface.from(0)));
    SimpleChooserOptionDefinition chooser = new SimpleChooserOptionDefinition(new Expiry(DATE), strike, UNDERLYING_EXPIRY);
    OptionDefinition vanilla = new EuropeanVanillaOptionDefinition(strike, UNDERLYING_EXPIRY, true);
    assertEquals(MODEL.getPricingFunction(chooser).evaluate(DATA), BSM.getPricingFunction(vanilla).evaluate(DATA), 1e-9);
    strike = SPOT / 2;
    chooser = new SimpleChooserOptionDefinition(new Expiry(DATE), strike, UNDERLYING_EXPIRY);
View Full Code Here

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

  }

  @Test
  public void test() {
    final double eps = 1e-4;
    StandardTwoAssetOptionDataBundle data = new StandardTwoAssetOptionDataBundle(R, B1, B2, SIGMA1, new VolatilitySurface(ConstantDoublesSurface.from(0.15)), S1, S2, -0.5, DATE);
    assertEquals(MODEL.getPricingFunction(OPTION1).evaluate(data), 2.1251, eps);
    assertEquals(MODEL.getPricingFunction(OPTION2).evaluate(data), 2.7619, eps);
    data = data.withCorrelation(0);
    assertEquals(MODEL.getPricingFunction(OPTION1).evaluate(data), 2.0446, eps);
    assertEquals(MODEL.getPricingFunction(OPTION2).evaluate(data), 2.4793, eps);
    data = data.withCorrelation(0.5);
    assertEquals(MODEL.getPricingFunction(OPTION1).evaluate(data), 1.9736, eps);
    assertEquals(MODEL.getPricingFunction(OPTION2).evaluate(data), 2.1378, eps);
    data = data.withSecondVolatilitySurface(new VolatilitySurface(ConstantDoublesSurface.from(0.2)));
    data = data.withCorrelation(-0.5);
    assertEquals(MODEL.getPricingFunction(OPTION1).evaluate(data), 2.1986, eps);
    assertEquals(MODEL.getPricingFunction(OPTION2).evaluate(data), 2.9881, eps);
    data = data.withCorrelation(0.);
    assertEquals(MODEL.getPricingFunction(OPTION1).evaluate(data), 2.0913, eps);
    assertEquals(MODEL.getPricingFunction(OPTION2).evaluate(data), 2.6496, eps);
    data = data.withCorrelation(0.5);
    assertEquals(MODEL.getPricingFunction(OPTION1).evaluate(data), 1.9891, eps);
    assertEquals(MODEL.getPricingFunction(OPTION2).evaluate(data), 2.2306, eps);
    data = data.withSecondVolatilitySurface(new VolatilitySurface(ConstantDoublesSurface.from(0.25)));
    data = data.withCorrelation(-0.5);
    assertEquals(MODEL.getPricingFunction(OPTION1).evaluate(data), 2.2827, eps);
    assertEquals(MODEL.getPricingFunction(OPTION2).evaluate(data), 3.2272, eps);
    data = data.withCorrelation(0.);
    assertEquals(MODEL.getPricingFunction(OPTION1).evaluate(data), 2.1520, eps);
View Full Code Here

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

  protected void assertValid(final AnalyticOptionModel<AmericanVanillaOptionDefinition, StandardOptionDataBundle> model, final double eps) {
    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

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

    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

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

    }
  }

  @Test
  public void testPriceTimeDependent() {
    final GeneralLogNormalOptionDataBundle data = new GeneralLogNormalOptionDataBundle(YIELD_CURVE, DRIFTLESS, new VolatilitySurface(FunctionalDoublesSurface.from(TIME_DEPENDENT_LOCAL_VOL)), FORWARD,
        DATE);
    final RecombiningBinomialTree<BinomialTreeNode<Double>> assetPriceTree = BUILDER.buildAssetTree(T, data, 200);
    RecombiningBinomialTree<BinomialTreeNode<Double>> optionPriceTree = BUILDER.buildOptionPriceTree(OPTION, data, assetPriceTree);
    final double vol = Math.sqrt(7.0 / 3.0) * ATM_VOL;
    EuropeanVanillaOption o = new EuropeanVanillaOption(FORWARD, T, true);
View Full Code Here

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

    }
  }

  @Test
  public void testCEV() {
    final GeneralLogNormalOptionDataBundle data = new GeneralLogNormalOptionDataBundle(YIELD_CURVE, DRIFTLESS, new VolatilitySurface(FunctionalDoublesSurface.from(CEV_LOCAL_VOL)), FORWARD, DATE);
    final RecombiningBinomialTree<BinomialTreeNode<Double>> assetPriceTree = BUILDER.buildAssetTree(T, data, 200);
    RecombiningBinomialTree<BinomialTreeNode<Double>> optionPriceTree = BUILDER.buildOptionPriceTree(OPTION, data, assetPriceTree);
    EuropeanVanillaOption o = new EuropeanVanillaOption(FORWARD, T, true);
    final CEVFunctionData cfd = new CEVFunctionData(FORWARD, YIELD_CURVE.getDiscountFactor(T), SIGMA_BETA, BETA);
View Full Code Here

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

    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
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.