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

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


    new DummyModel(N, STEPS, PROCESS, null);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testNullDefinition() {
    MODEL.getGreeks(null, new StandardOptionDataBundle(null, 0, null, 100, DateUtils.getUTCDate(2010, 1, 1)), Sets.newHashSet(Greek.FAIR_PRICE));
  }
View Full Code Here


    MODEL.getGreeks(new EuropeanVanillaOptionDefinition(100, new Expiry(DateUtils.getUTCDate(2010, 1, 1)), true), null, Sets.newHashSet(Greek.FAIR_PRICE));
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testNullGreeks() {
    MODEL.getGreeks(new EuropeanVanillaOptionDefinition(100, new Expiry(DateUtils.getUTCDate(2010, 1, 1)), true), new StandardOptionDataBundle(null, 0, null, 100, DateUtils.getUTCDate(2010, 1, 1)),
        null);
  }
View Full Code Here

        null);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testEmptyGreeks() {
    MODEL.getGreeks(new EuropeanVanillaOptionDefinition(100, new Expiry(DateUtils.getUTCDate(2010, 1, 1)), true), new StandardOptionDataBundle(null, 0, null, 100, DateUtils.getUTCDate(2010, 1, 1)),
        Collections.<Greek> emptySet());
  }
View Full Code Here

        Collections.<Greek> emptySet());
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testWrongGreeks() {
    MODEL.getGreeks(new EuropeanVanillaOptionDefinition(100, new Expiry(DateUtils.getUTCDate(2010, 1, 1)), true), new StandardOptionDataBundle(null, 0, null, 100, DateUtils.getUTCDate(2010, 1, 1)),
        Sets.newHashSet(Greek.DELTA, Greek.GAMMA));
  }
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

    assertEquals(MODEL.getPricingFunction(option).evaluate(data), REBATE, 0);
  }

  @Test
  public void test() {
    final StandardOptionDataBundle data = new StandardOptionDataBundle(R, B, new VolatilitySurface(ConstantDoublesSurface.from(0.25)), SPOT, DATE);
    Barrier barrier = new Barrier(KnockType.OUT, BarrierType.DOWN, ObservationType.CONTINUOUS, 95);
    EuropeanStandardBarrierOptionDefinition option = new EuropeanStandardBarrierOptionDefinition(90, EXPIRY, true, barrier, REBATE);
    assertEquals(MODEL.getPricingFunction(option).evaluate(data), 9.0246, EPS);
    barrier = new Barrier(KnockType.OUT, BarrierType.UP, ObservationType.CONTINUOUS, 105);
    option = new EuropeanStandardBarrierOptionDefinition(90, EXPIRY, true, barrier, REBATE);
View Full Code Here

    }
    final double spot = spotAsObject;
    final YieldAndDiscountCurve curve = YieldCurve.from(ConstantDoublesCurve.from(0.));
    final VolatilitySurface volatilitySurface = (VolatilitySurface) inputs.getValue(ValueRequirementNames.VOLATILITY_SURFACE);
    final double b = 0;
    return new StandardOptionDataBundle(curve, b, volatilitySurface, spot, now);
  }
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.