final double vols[] = { 0.11, 0.50, 1.20 };
final DayCounter dc = new Actual360();
final Date today = new Settings().evaluationDate();
final SimpleQuote spot = new SimpleQuote(0.0);
final SimpleQuote qRate = new SimpleQuote(0.0);
final YieldTermStructure qTS = Utilities.flatRate(today, qRate, dc);
final SimpleQuote rRate = new SimpleQuote(0.0);
final YieldTermStructure rTS = Utilities.flatRate(today, rRate, dc);
final SimpleQuote vol = new SimpleQuote(0.0);
final BlackVolTermStructure volTS = Utilities.flatVol(today, vol, dc);
for (final Type type : types) {
for (final double strike : strikes) {
for (final int year : years) {
final Date exDate = today.add(new Period(year, TimeUnit.Years));
final Exercise exercise = new AmericanExercise(today, exDate);
final StrikedTypePayoff payoff = new PlainVanillaPayoff(type, strike);
final BlackScholesMertonProcess stochProcess = new BlackScholesMertonProcess(
new Handle<Quote>(spot),
new Handle<YieldTermStructure>(qTS),
new Handle<YieldTermStructure>(rTS),
new Handle<BlackVolTermStructure>(volTS));
PricingEngine engine = null;
try {
final Constructor<? extends PricingEngine> c = klass.getConstructor(GeneralizedBlackScholesProcess.class);
engine = c.newInstance(stochProcess);
} catch (final Exception e) {
e.printStackTrace();
fail("failed to create pricing engine");
}
final VanillaOption option = new VanillaOption(payoff, exercise);
option.setPricingEngine(engine);
for (final double u : underlyings) {
for (final double q : qRates) {
for (final double r : rRates) {
for (final double v : vols) {
spot.setValue(u);
qRate.setValue(q);
rRate.setValue(r);
vol.setValue(v);
// FLOATING_POINT_EXCEPTION
final double value = option.NPV();
final double delta = option.delta();
final double gamma = option.gamma();
//final double theta = option.theta();