ProductOptionDefinition extends OptionDefinition { @SuppressWarnings("unchecked") @Override public OptionPayoffFunction<StandardTwoAssetOptionDataBundle> getPayoffFunction() { return _payoffFunction; } ProductOptionDefinition(final double strike, final Expiry expiry, final boolean isCall); @SuppressWarnings("unchecked") @Override OptionExerciseFunction<StandardTwoAssetOptionDataBundle> getExerciseFunction(); @SuppressWarnings("unchecked") @Override OptionPayoffFunction<StandardTwoAssetOptionDataBundle> getPayoffFunction();  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullData() { new ProductOptionDefinition(K, EXPIRY, true).getPayoffFunction().getPayoff(null, null); }
@Test public void testPayoff() { final ProductOptionDefinition call = new ProductOptionDefinition(K, EXPIRY, true); final ProductOptionDefinition put = new ProductOptionDefinition(K, EXPIRY, false); final double eps = 1e-12; assertEquals(call.getPayoffFunction().getPayoff(DATA, null), 0, eps); assertEquals(put.getPayoffFunction().getPayoff(DATA, null), 0, eps); StandardTwoAssetOptionDataBundle data = DATA.withSecondSpot(8); assertEquals(call.getPayoffFunction().getPayoff(data, null), 0, eps); assertEquals(put.getPayoffFunction().getPayoff(data, null), 10, eps); data = DATA.withSecondSpot(10); assertEquals(call.getPayoffFunction().getPayoff(data, null), 10, eps); assertEquals(put.getPayoffFunction().getPayoff(data, null), 0, eps); }