Package com.opengamma.analytics.financial.model.volatility.surface

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


  }

  @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);
View Full Code Here


  private static final double EPS = 1e-4;

  @Test
  public void test() {
    DoubleTimeSeries<?> ts = ImmutableZonedDateTimeDoubleTimeSeries.ofUTC(new ZonedDateTime[] {DateUtils.getUTCDate(2010, 6, 1), DateUtils.getUTCDate(2010, 11, 1)}, new double[] {SPOT, 100});
    StandardOptionWithSpotTimeSeriesDataBundle data = new StandardOptionWithSpotTimeSeriesDataBundle(CURVE, B, new VolatilitySurface(ConstantDoublesSurface.from(0.15)), SPOT, DATE, ts);
    ExtremeSpreadOptionDefinition option = new ExtremeSpreadOptionDefinition(EXPIRY, true, new Expiry(DateUtils.getDateOffsetWithYearFraction(DATE, 0.25)), false);
    assertEquals(MODEL.getPricingFunction(option).evaluate(data), 10.6618, EPS);
    ts = ImmutableZonedDateTimeDoubleTimeSeries.ofUTC(new ZonedDateTime[] {DateUtils.getUTCDate(2010, 6, 1), DateUtils.getUTCDate(2010, 11, 1)}, new double[] {SPOT, 110});
    data = data.withSpotTimeSeries(ts);
    assertEquals(MODEL.getPricingFunction(option).evaluate(data), 8.4878, EPS);
    ts = ImmutableZonedDateTimeDoubleTimeSeries.ofUTC(new ZonedDateTime[] {DateUtils.getUTCDate(2010, 6, 1), DateUtils.getUTCDate(2010, 11, 1)}, new double[] {SPOT, 120});
    data = data.withSpotTimeSeries(ts);
    assertEquals(MODEL.getPricingFunction(option).evaluate(data), 4.5235, EPS);
    option = new ExtremeSpreadOptionDefinition(EXPIRY, true, new Expiry(DateUtils.getDateOffsetWithYearFraction(DATE, 0.75)), true);
    data = data.withVolatilitySurface(new VolatilitySurface(ConstantDoublesSurface.from(0.3)));
    ts = ImmutableZonedDateTimeDoubleTimeSeries.ofUTC(new ZonedDateTime[] {DateUtils.getUTCDate(2010, 6, 1), DateUtils.getUTCDate(2010, 11, 1)}, new double[] {SPOT, 100});
    data = data.withSpotTimeSeries(ts);
    assertEquals(MODEL.getPricingFunction(option).evaluate(data), 13.3404, EPS);
    ts = ImmutableZonedDateTimeDoubleTimeSeries.ofUTC(new ZonedDateTime[] {DateUtils.getUTCDate(2010, 6, 1), DateUtils.getUTCDate(2010, 11, 1)}, new double[] {SPOT, 90});
    data = data.withSpotTimeSeries(ts);
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);
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

    }
  }

  @Test
  public void testPriceTimeDependent() {
    final GeneralNormalOptionDataBundle data = new GeneralNormalOptionDataBundle(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);
    final BlackFunctionData bfd = new BlackFunctionData(FORWARD, YIELD_CURVE.getDiscountFactor(T), 0);
View Full Code Here

    }
  }

  @Test
  public void testCEV() {
    final GeneralNormalOptionDataBundle data = new GeneralNormalOptionDataBundle(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);
    for (int i = 0; i < 10; i++) {
      final double m = -1.5 + 3.0 * i / 10.0;
      final double strike = FORWARD * Math.exp(ATM_VOL * Math.sqrt(T) * m);
 
View Full Code Here

  }

  private void assertPrices(final Set<Greek> greeks, final double strike, final Expiry expiry, final boolean isCall, final double r, final double b, final double sigma, final double spot,
      final GreekResultCollection expected) {
    final EuropeanVanillaOptionDefinition definition = new EuropeanVanillaOptionDefinition(strike, expiry, isCall);
    final StandardOptionDataBundle data = new StandardOptionDataBundle(YieldCurve.from(ConstantDoublesCurve.from(r)), b, new VolatilitySurface(ConstantDoublesSurface.from(sigma)), spot, DATE);
    final GreekResultCollection result = MODEL.getGreeks(definition, data, greeks);
    assertResults(result, expected);
    assertPutCallParity(strike, expiry, r, b, sigma, spot);
  }
View Full Code Here

  }

  private void assertGreek(final Greek greek, final double strike, final Expiry expiry, final boolean isCall, final double r, final double b, final double sigma, final double spot,
      final GreekResultCollection expected) {
    final EuropeanVanillaOptionDefinition definition = new EuropeanVanillaOptionDefinition(strike, expiry, isCall);
    final StandardOptionDataBundle data = new StandardOptionDataBundle(YieldCurve.from(ConstantDoublesCurve.from(r)), b, new VolatilitySurface(ConstantDoublesSurface.from(sigma)), spot, DATE);
    final GreekResultCollection result = MODEL.getGreeks(definition, data, Collections.singleton(greek));
    assertResults(result, expected);
  }
View Full Code Here

  private void assertPutCallParity(final double strike, final Expiry expiry, final double r, final double b, final double sigma, final double spot) {
    final Set<Greek> greeks = Collections.singleton(Greek.FAIR_PRICE);
    final EuropeanVanillaOptionDefinition call = new EuropeanVanillaOptionDefinition(strike, expiry, true);
    final EuropeanVanillaOptionDefinition put = new EuropeanVanillaOptionDefinition(strike, expiry, false);
    final StandardOptionDataBundle data = new StandardOptionDataBundle(YieldCurve.from(ConstantDoublesCurve.from(r)), b, new VolatilitySurface(ConstantDoublesSurface.from(sigma)), spot, DATE);
    final GreekResultCollection callResult = MODEL.getGreeks(call, data, greeks);
    final GreekResultCollection putResult = MODEL.getGreeks(put, data, greeks);
    final Double c = callResult.values().iterator().next();
    final Double p = putResult.values().iterator().next();
    final double t = call.getTimeToExpiry(DATE);
View Full Code Here

  }

  @Test
  public void testZeroVol() {
    final double delta = 10;
    final StandardOptionDataBundle data = new StandardOptionDataBundle(YieldCurve.from(ConstantDoublesCurve.from(0.)), 0, new VolatilitySurface(ConstantDoublesSurface.from(0.)), SPOT, DATE);
    Barrier barrier = new Barrier(KnockType.OUT, BarrierType.DOWN, ObservationType.CONTINUOUS, 95);
    EuropeanStandardBarrierOptionDefinition option = new EuropeanStandardBarrierOptionDefinition(SPOT - delta, EXPIRY, true, barrier, REBATE);
    assertEquals(MODEL.getPricingFunction(option).evaluate(data), 10, 0);
    barrier = new Barrier(KnockType.IN, BarrierType.UP, ObservationType.CONTINUOUS, 105);
    option = new EuropeanStandardBarrierOptionDefinition(SPOT - delta, EXPIRY, true, barrier, REBATE);
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.model.volatility.surface.VolatilitySurface

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.