Examples of EuropeanVanillaOptionDefinition


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

  private PoweredOptionDefinition getPoweredDefinition(final double power, final boolean isCall) {
    return new PoweredOptionDefinition(STRIKE, EXPIRY, power, isCall);
  }

  private EuropeanVanillaOptionDefinition getVanillaOption(final boolean isCall) {
    return new EuropeanVanillaOptionDefinition(STRIKE, EXPIRY, isCall);
  }
View Full Code Here

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

  }

  @Test
  public void test() {
    assertEquals(MODEL.getPricingFunction(OPTION).evaluate(DATA), 21.196, 1e-3);
    final EuropeanVanillaOptionDefinition call = new EuropeanVanillaOptionDefinition(UNDERLYING_STRIKE, UNDERLYING_EXPIRY, true);
    final EuropeanVanillaOptionDefinition put = new EuropeanVanillaOptionDefinition(UNDERLYING_STRIKE, EXPIRY, false);
    final EuropeanOptionOnEuropeanVanillaOptionDefinition callOnCall = new EuropeanOptionOnEuropeanVanillaOptionDefinition(STRIKE, EXPIRY, true, call);
    final EuropeanOptionOnEuropeanVanillaOptionDefinition putOnCall = new EuropeanOptionOnEuropeanVanillaOptionDefinition(STRIKE, EXPIRY, false, call);
    assertEquals(MODEL.getPricingFunction(callOnCall).evaluate(DATA) - MODEL.getPricingFunction(putOnCall).evaluate(DATA),
        BSM.getPricingFunction(call).evaluate(DATA) - STRIKE * Math.exp(-0.08 * 0.25), 1e-3);
    final EuropeanOptionOnEuropeanVanillaOptionDefinition callOnPut = new EuropeanOptionOnEuropeanVanillaOptionDefinition(STRIKE, EXPIRY, true, put);
View Full Code Here

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

    MODEL.getGreeks(null, new StandardOptionDataBundle(null, 0, null, 100, DateUtils.getUTCDate(2010, 1, 1)), Sets.newHashSet(Greek.FAIR_PRICE));
  }

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

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

    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

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

        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

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

        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

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

        Sets.newHashSet(Greek.DELTA, Greek.GAMMA));
  }

  @Test
  public void testPriceOnly() {
    final GreekResultCollection result = 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.FAIR_PRICE, Greek.DELTA, Greek.GAMMA));
    assertEquals(result.size(), 1);
    assertEquals(result.keySet().iterator().next(), Greek.FAIR_PRICE);
    assertEquals(result.values().iterator().next(), 2., 0);
  }
View Full Code Here

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

  private static final double EPS = 2e-2;

  @Test
  public void testEuropeanOption() {
    final int n = 1001;
    final OptionDefinition call1 = new EuropeanVanillaOptionDefinition(SPOT * .9, EXPIRY, true);
    final OptionDefinition put1 = new EuropeanVanillaOptionDefinition(SPOT * .9, EXPIRY, false);
    final OptionDefinition call2 = new EuropeanVanillaOptionDefinition(SPOT * 1.1, EXPIRY, true);
    final OptionDefinition put2 = new EuropeanVanillaOptionDefinition(SPOT * 1.1, EXPIRY, false);
    final AnalyticOptionModel<OptionDefinition, StandardOptionDataBundle> bsm = new BlackScholesMertonModel();
    TreeOptionModel<OptionDefinition, StandardOptionDataBundle> treeModel = new BinomialOptionModel<>(CRR, n, 5);
    assertGreeks(call1, treeModel, bsm);
    assertGreeks(put1, treeModel, bsm);
    assertGreeks(call2, treeModel, bsm);
View Full Code Here

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

    //double impVol = BlackImpliedVolFormula.impliedVol(optionPriceTree.getNode(0, 0).getValue(), FORWARD, FORWARD, YIELD_CURVE.getDiscountFactor(T), T, true);
    assertEquals(ATM_VOL, impVol, 1e-3);
    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);
      final OptionDefinition option = new EuropeanVanillaOptionDefinition(strike, OPTION.getExpiry(), OPTION.isCall());
      o = new EuropeanVanillaOption(strike, T, OPTION.isCall());
      optionPriceTree = BUILDER.buildOptionPriceTree(option, DATA, assetPriceTree);
      impVol = BLACK_IMPLIED_VOL.getImpliedVolatility(data, o, optionPriceTree.getNode(0, 0).getValue());
      //impVol = BlackImpliedVolFormula.impliedVol(optionPriceTree.getNode(0, 0).getValue(), FORWARD, strike, YIELD_CURVE.getDiscountFactor(T), T, true);
      // System.out.println(strike+"\t"+impVol);
View Full Code Here

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

    //    double impVol = BlackImpliedVolFormula.impliedVol(optionPriceTree.getNode(0, 0).getValue(), FORWARD, FORWARD, df, T, true);
    assertEquals(vol, impVol, 1e-3);
    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);
      final OptionDefinition option = new EuropeanVanillaOptionDefinition(strike, OPTION.getExpiry(), OPTION.isCall());
      optionPriceTree = BUILDER.buildOptionPriceTree(option, data, assetPriceTree);
      o = new EuropeanVanillaOption(strike, T, OPTION.isCall());
      optionPriceTree = BUILDER.buildOptionPriceTree(option, DATA, assetPriceTree);
      impVol = BLACK_IMPLIED_VOL.getImpliedVolatility(bfd, o, optionPriceTree.getNode(0, 0).getValue());
      //impVol = BlackImpliedVolFormula.impliedVol(optionPriceTree.getNode(0, 0).getValue(), FORWARD, strike, df, T, true);
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.