CashOrNothingOptionDefinition extends OptionDefinition { @Override public OptionPayoffFunction<StandardOptionDataBundle> getPayoffFunction() { return _payoffFunction; } CashOrNothingOptionDefinition(final double strike, final Expiry expiry, final boolean isCall, final double payment); @Override OptionExerciseFunction<StandardOptionDataBundle> getExerciseFunction(); @Override OptionPayoffFunction<StandardOptionDataBundle> getPayoffFunction(); double getPayment(); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullData() { CALL.getPayoffFunction().getPayoff(null, null); }
@Test public void testPayoffFunction() { OptionPayoffFunction<StandardOptionDataBundle> f = CALL.getPayoffFunction(); final double delta = 40; assertEquals(f.getPayoff(DATA.withSpot(SPOT + delta), null), 0, 0); assertEquals(f.getPayoff(DATA.withSpot(SPOT - delta), null), PAYMENT, 0); f = PUT.getPayoffFunction(); assertEquals(f.getPayoff(DATA.withSpot(SPOT + delta), null), PAYMENT, 0); assertEquals(f.getPayoff(DATA.withSpot(SPOT - delta), null), 0, 0); }