Examples of AmericanVanillaOptionDefinition


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

    }
  }

  public void testAmericanPrice(final ConvectionDiffusionPDESolver solver, final int timeSteps, final int priceSteps, final double lowerMoneyness, final double upperMoneyness, final boolean print) {

    final AmericanVanillaOptionDefinition option = new AmericanVanillaOptionDefinition(FORWARD, new Expiry(DateUtils.getDateOffsetWithYearFraction(DATE, T)), false);
    final BjerksundStenslandModel model = new BjerksundStenslandModel();
    final Function1D<StandardOptionDataBundle, Double> pFunc = model.getPricingFunction(option);

    final PDEGrid1D grid = new PDEGrid1D(timeSteps + 1, priceSteps + 1, T, LOWER.getLevel(), UPPER.getLevel());
    final PDE1DDataBundle<ConvectionDiffusionPDE1DCoefficients> db = new PDE1DDataBundle<ConvectionDiffusionPDE1DCoefficients>(DATA, PAYOFF, LOWER, UPPER, EARLY_EXCISE, grid);
View Full Code Here

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

  @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);
    expected[1][0] = DoublesPair.of(90.91, 9.2356);
View Full Code Here

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

  private static final double SIGMA2 = 0.25;
  private static final double SIGMA3 = 0.35;
  private static final Set<Greek> GREEK_SET = Collections.singleton(Greek.FAIR_PRICE);

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

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

  }

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

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

    return _model;
  }

  @Override
  protected AmericanVanillaOptionDefinition getOptionDefinition(final EquityOptionSecurity option) {
    return new AmericanVanillaOptionDefinition(option.getStrike(), option.getExpiry(), option.getOptionType() == OptionType.CALL);
  }
View Full Code Here

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

  protected OptionDefinition getOptionDefinition(final EquityOptionSecurity option) {
    return option.getExerciseType().accept(
      new ExerciseTypeVisitor<OptionDefinition>() {
        @Override
        public OptionDefinition visitAmericanExerciseType(final AmericanExerciseType exerciseType) {
          return new AmericanVanillaOptionDefinition(option.getStrike(), option.getExpiry(), option.getOptionType() == OptionType.CALL);
        }

        @Override
        public OptionDefinition visitAsianExerciseType(final AsianExerciseType exerciseType) {
          throw new OpenGammaRuntimeException("Unsupported option type: Asian");
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.