Package com.opengamma.analytics.financial.greeks

Examples of com.opengamma.analytics.financial.greeks.GreekResultCollection


    assertPriceEquals(definition, 0.3, 3745.1853);
  }

  private void assertPriceEquals(final PoweredOptionDefinition poweredDefinition, final EuropeanVanillaOptionDefinition vanillaDefinition, final double sigma) {
    final StandardOptionDataBundle bundle = getBundle(sigma);
    final GreekResultCollection actual = POWERED_MODEL.getGreeks(poweredDefinition, bundle, REQUIRED_GREEKS);
    final GreekResultCollection expected = BSM.getGreeks(vanillaDefinition, bundle, REQUIRED_GREEKS);
    assertEquals(expected.get(Greek.FAIR_PRICE), actual.get(Greek.FAIR_PRICE), SMALL_EPS);
  }
View Full Code Here


    assertEquals(expected.get(Greek.FAIR_PRICE), actual.get(Greek.FAIR_PRICE), SMALL_EPS);
  }

  private void assertPriceEquals(final PoweredOptionDefinition poweredDefinition, final double sigma, final double price) {
    final StandardOptionDataBundle bundle = getBundle(sigma);
    final GreekResultCollection actual = POWERED_MODEL.getGreeks(poweredDefinition, bundle, REQUIRED_GREEKS);
    assertEquals(price, actual.get(Greek.FAIR_PRICE), BIG_EPS * price);
  }
View Full Code Here

              final double priceTimeUp = price(SPOT, strike, TIME + eps, vol, interest, dividend, isCall, lower, upper);
              final double priceTimeDown = price(SPOT, strike, TIME - eps, vol, interest, dividend, isCall, lower, upper);
              final double gamma = 0.5 * (deltaSpotUp - deltaSpotDown) / eps;
              final double theta = -0.5 * (priceTimeUp - priceTimeDown) / eps;

              final GreekResultCollection res = _modelTrinomial.getGreeks(lattice, function, SPOT, vol, interest, dividend);
              assertEquals(res.get(Greek.FAIR_PRICE), price, Math.max(price, .1) * 1.e-1);
              assertEquals(res.get(Greek.DELTA), delta, Math.max(delta, .1) * 1.e-1);
              assertEquals(res.get(Greek.GAMMA), gamma, Math.max(gamma, .1) * 1.e-1);
              assertEquals(res.get(Greek.THETA), theta, Math.max(theta, 1.) * 1.e-1);
            }
          }
        }
      }
    }
View Full Code Here

      final OptionFunctionProvider1D functionPut = new DoubleBarrierOptionFunctionProvider(SPOT * SPOT / strike, TIME, steps, false, SPOT * SPOT / upper, SPOT * SPOT / lower, out);
      for (final double interest : INTERESTS) {
        for (final double vol : VOLS) {
          for (final double dividend : DIVIDENDS) {
            for (final LatticeSpecification lattice : lattices) {
              final GreekResultCollection greekCall = _model.getGreeks(lattice, functionCall, SPOT, vol, interest, dividend);
              final GreekResultCollection greekPut = _model.getGreeks(lattice, functionPut, SPOT, vol, dividend, interest);
              final double priceCall = greekCall.get(Greek.FAIR_PRICE);
              final double thetaCall = greekCall.get(Greek.THETA);
              final double pricePut = greekPut.get(Greek.FAIR_PRICE);
              final double thetaPut = greekPut.get(Greek.THETA);
              final double refPrice = strike * pricePut / SPOT;
              final double refTheta = strike * thetaPut / SPOT;
              assertEquals(priceCall, refPrice, Math.max(refPrice, 0.1) * 1.e-5);
              assertEquals(thetaCall, refTheta, Math.max(Math.abs(refTheta), 0.1) * 1.e-2);
            }
View Full Code Here

              final double priceTimeUp = price(SPOT, strike, TIME + eps, vol, interest, dividend, isCall, lower, upper);
              final double priceTimeDown = price(SPOT, strike, TIME - eps, vol, interest, dividend, isCall, lower, upper);
              final double gamma = 0.5 * (deltaSpotUp - deltaSpotDown) / eps;
              final double theta = -0.5 * (priceTimeUp - priceTimeDown) / eps;

              final GreekResultCollection res = _model.getGreeks(lattice, function, SPOT, vol, interest, dividend);
              assertEquals(res.get(Greek.FAIR_PRICE), price, Math.max(price, .1) * 1.e-1);
              assertEquals(res.get(Greek.DELTA), delta, Math.max(delta, .1) * 1.e-1);
              assertEquals(res.get(Greek.GAMMA), gamma, Math.max(gamma, .1) * 1.e-1);
              assertEquals(res.get(Greek.THETA), theta, Math.max(theta, .1) * 1.e-1);
            }
          }
        }
      }
    }
View Full Code Here

              final double priceTimeUp = price(SPOT, strike, TIME + eps, vol, interest, dividend, isCall, lower[i], upper[i]);
              final double priceTimeDown = price(SPOT, strike, TIME - eps, vol, interest, dividend, isCall, lower[i], upper[i]);
              final double gamma = 0.5 * (deltaSpotUp - deltaSpotDown) / eps;
              final double theta = -0.5 * (priceTimeUp - priceTimeDown) / eps;

              final GreekResultCollection res = _model.getGreeks(lattice, function, SPOT, vol, interest, dividend);
              assertEquals(res.get(Greek.FAIR_PRICE), price, Math.max(price, 1.) * 1.e-3);
              assertEquals(res.get(Greek.DELTA), delta, Math.max(delta, 1.) * 1.e-3);
              assertEquals(res.get(Greek.GAMMA), gamma, Math.max(gamma, 1.) * 1.e-3);
              assertEquals(res.get(Greek.THETA), theta, Math.max(theta, 1.) * 1.e-3);
            }
          }
        }
      }
    }
View Full Code Here

          for (int i = 0; i < lower.length; ++i) {
            final OptionFunctionProvider1D function = new DoubleBarrierOptionFunctionProvider(strike, TIME, steps, isCall, lower[i], upper[i],
                DoubleBarrierOptionFunctionProvider.BarrierTypes.valueOf("DoubleKnockOut"));
            final double priceCash = _model.getPrice(lattice, function, SPOT, vol, interest, cashDividend);
            final double priceProp = _model.getPrice(lattice, function, SPOT, vol, interest, propDividend);
            final GreekResultCollection resCash = _model.getGreeks(lattice, function, SPOT, vol, interest, cashDividend);
            final GreekResultCollection resProp = _model.getGreeks(lattice, function, SPOT, vol, interest, propDividend);
            final OptionFunctionProvider1D functionTri = new DoubleBarrierOptionFunctionProvider(strike, TIME, stepsTri, isCall, lower[i], upper[i],
                DoubleBarrierOptionFunctionProvider.BarrierTypes.valueOf("DoubleKnockOut"));
            final double priceCashTrinomial = _modelTrinomial.getPrice(lattice, functionTri, SPOT, vol, interest, cashDividend);
            final double pricePropTrinomial = _modelTrinomial.getPrice(lattice, functionTri, SPOT, vol, interest, propDividend);
            final GreekResultCollection resCashTrinomial = _modelTrinomial.getGreeks(lattice, functionTri, SPOT, vol, interest, cashDividend);
            final GreekResultCollection resPropTrinomial = _modelTrinomial.getGreeks(lattice, functionTri, SPOT, vol, interest, propDividend);

            assertEquals(resCash.get(Greek.FAIR_PRICE), priceCash, 1.e-14);
            assertEquals(resCashTrinomial.get(Greek.FAIR_PRICE), priceCashTrinomial, 1.e-14);
            assertEquals(resCash.get(Greek.FAIR_PRICE), resCashTrinomial.get(Greek.FAIR_PRICE), Math.max(Math.abs(resCashTrinomial.get(Greek.FAIR_PRICE)), 1.) * 1.e-1);
            assertEquals(resCash.get(Greek.DELTA), resCashTrinomial.get(Greek.DELTA), Math.max(Math.abs(resCashTrinomial.get(Greek.DELTA)), 1.) * 1.e-1);
            assertEquals(resCash.get(Greek.GAMMA), resCashTrinomial.get(Greek.GAMMA), Math.max(Math.abs(resCashTrinomial.get(Greek.GAMMA)), 1.) * 1.e-1);
            assertEquals(resCash.get(Greek.THETA), resCashTrinomial.get(Greek.THETA), Math.max(Math.abs(resCashTrinomial.get(Greek.THETA)), 1.) * 1.);

            assertEquals(resProp.get(Greek.FAIR_PRICE), priceProp, 1.e-14);
            assertEquals(resPropTrinomial.get(Greek.FAIR_PRICE), pricePropTrinomial, 1.e-14);
            assertEquals(resProp.get(Greek.FAIR_PRICE), resPropTrinomial.get(Greek.FAIR_PRICE), Math.max(Math.abs(resPropTrinomial.get(Greek.FAIR_PRICE)), 1.) * 1.e-1);
            assertEquals(resProp.get(Greek.DELTA), resPropTrinomial.get(Greek.DELTA), Math.max(Math.abs(resPropTrinomial.get(Greek.DELTA)), 1.) * 1.e-1);
            assertEquals(resProp.get(Greek.GAMMA), resPropTrinomial.get(Greek.GAMMA), Math.max(Math.abs(resPropTrinomial.get(Greek.GAMMA)), 1.) * 1.e-1);
            assertEquals(resProp.get(Greek.THETA), resPropTrinomial.get(Greek.THETA), Math.max(Math.abs(resPropTrinomial.get(Greek.THETA)), 1.) * 1.);
          }
        }
      }
    }
  }
View Full Code Here

        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

        for (int i = 0; i < lower.length; ++i) {
          final OptionFunctionProvider1D functionVanilla = new DoubleBarrierOptionFunctionProvider(strike, TIME, steps, isCall, lower[i], upper[i],
              DoubleBarrierOptionFunctionProvider.BarrierTypes.valueOf("DoubleKnockOut"));
          final double resPrice = _model.getPrice(functionVanilla, SPOT, vol, rate, dividend);
          final GreekResultCollection resGreeks = _model.getGreeks(functionVanilla, SPOT, vol, rate, dividend);

          final double resPriceConst = _model.getPrice(lattice1, functionVanilla, SPOT, volRef, rateRef, dividend[0]);
          final GreekResultCollection resGreeksConst = _model.getGreeks(lattice1, functionVanilla, SPOT, volRef, rateRef, dividend[0]);
          assertEquals(resPrice, resPriceConst, Math.max(Math.abs(resPriceConst), .1) * 1.e-1);
          assertEquals(resGreeks.get(Greek.FAIR_PRICE), resGreeksConst.get(Greek.FAIR_PRICE), Math.max(Math.abs(resGreeksConst.get(Greek.FAIR_PRICE)), 0.1) * 0.1);
          assertEquals(resGreeks.get(Greek.DELTA), resGreeksConst.get(Greek.DELTA), Math.max(Math.abs(resGreeksConst.get(Greek.DELTA)), 0.1) * 0.1);
          assertEquals(resGreeks.get(Greek.GAMMA), resGreeksConst.get(Greek.GAMMA), Math.max(Math.abs(resGreeksConst.get(Greek.GAMMA)), 0.1) * 0.1);
          assertEquals(resGreeks.get(Greek.THETA), resGreeksConst.get(Greek.THETA), Math.max(Math.abs(resGreeksConst.get(Greek.THETA)), 0.1));

          final OptionFunctionProvider1D functionTri = new DoubleBarrierOptionFunctionProvider(strike, TIME, stepsTri, isCall, lower[i], upper[i],
              DoubleBarrierOptionFunctionProvider.BarrierTypes.valueOf("DoubleKnockOut"));
          final double resPriceTrinomial = _modelTrinomial.getPrice(functionTri, SPOT, volTri, rateTri, dividendTri);
          assertEquals(resPriceTrinomial, resPriceConst, Math.max(Math.abs(resPriceConst), 1.) * 1.e-1);
          final GreekResultCollection resGreeksTrinomial = _modelTrinomial.getGreeks(functionTri, SPOT, volTri, rateTri, dividendTri);
          assertEquals(resGreeksTrinomial.get(Greek.FAIR_PRICE), resGreeksConst.get(Greek.FAIR_PRICE), Math.max(Math.abs(resGreeksConst.get(Greek.FAIR_PRICE)), 1.) * 0.1);
          assertEquals(resGreeksTrinomial.get(Greek.DELTA), resGreeksConst.get(Greek.DELTA), Math.max(Math.abs(resGreeksConst.get(Greek.DELTA)), 1.) * 0.1);
          assertEquals(resGreeksTrinomial.get(Greek.GAMMA), resGreeksConst.get(Greek.GAMMA), Math.max(Math.abs(resGreeksConst.get(Greek.GAMMA)), 1.) * 0.1);
          assertEquals(resGreeksTrinomial.get(Greek.THETA), resGreeksConst.get(Greek.THETA), Math.max(Math.abs(resGreeksConst.get(Greek.THETA)), 1.));
        }
      }
    }
  }
View Full Code Here

      final OptionFunctionProvider1D functionPut = new AmericanVanillaOptionFunctionProvider(SPOT * SPOT / strike, TIME, steps, false);
      for (final double interest : INTERESTS) {
        for (final double vol : VOLS) {
          for (final double dividend : DIVIDENDS) {
            for (final LatticeSpecification lattice : lattices) {
              final GreekResultCollection greekCall = _model.getGreeks(lattice, functionCall, SPOT, vol, interest, dividend);
              final GreekResultCollection greekPut = _model.getGreeks(lattice, functionPut, SPOT, vol, dividend, interest);
              final double priceCall = greekCall.get(Greek.FAIR_PRICE);
              final double thetaCall = greekCall.get(Greek.THETA);
              final double pricePut = greekPut.get(Greek.FAIR_PRICE);
              final double thetaPut = greekPut.get(Greek.THETA);
              final double refPrice = strike * pricePut / SPOT;
              final double refTheta = strike * thetaPut / SPOT;
              assertEquals(priceCall, refPrice, Math.max(refPrice, 1.) * 1.e-5);
              assertEquals(thetaCall, refTheta, Math.max(Math.abs(refTheta), 1.) * 1.e-2);
            }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.greeks.GreekResultCollection

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.