} 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();
calculated.put("delta", delta);
calculated.put("gamma", gamma);
//calculated.put("theta", theta);
if (value > spot.value() * 1.0e-5) {
// perturb spot and get delta and gamma
final double du = u * 1.0e-4;
spot.setValue(u + du);
final double value_p = option.NPV();
final double delta_p = option.delta();
spot.setValue(u - du);
final double value_m = option.NPV();
final double delta_m = option.delta();
spot.setValue(u);
expected.put("delta", (value_p - value_m) / (2 * du));
expected.put("gamma", (delta_p - delta_m) / (2 * du));
/*