AmericanVanillaOptionDefinition extends OptionDefinition { @Override public OptionPayoffFunction<StandardOptionDataBundle> getPayoffFunction() { return _payoffFunction; } AmericanVanillaOptionDefinition(final double strike, final Expiry expiry, final boolean isCall); @Override OptionExerciseFunction<StandardOptionDataBundle> getExerciseFunction(); @Override OptionPayoffFunction<StandardOptionDataBundle> getPayoffFunction(); @Override String toString(); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullDataInPayoff() { CALL.getPayoffFunction().getPayoff(null, LOW_PRICE); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullOptionPriceInPayoff() { CALL.getPayoffFunction().getPayoff(DATA, null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNegativeOptionPriceInPayoff() { CALL.getPayoffFunction().getPayoff(DATA, -LOW_PRICE); }
@Test public void testPayoffFunction() { OptionPayoffFunction<StandardOptionDataBundle> payoff = CALL.getPayoffFunction(); assertEquals(payoff.getPayoff(DATA.withSpot(STRIKE + DIFF), LOW_PRICE), DIFF, EPS); assertEquals(payoff.getPayoff(DATA.withSpot(STRIKE - DIFF), LOW_PRICE), LOW_PRICE, EPS); assertEquals(payoff.getPayoff(DATA.withSpot(STRIKE + DIFF), HIGH_PRICE), HIGH_PRICE, EPS); assertEquals(payoff.getPayoff(DATA.withSpot(STRIKE - DIFF), HIGH_PRICE), HIGH_PRICE, EPS); payoff = PUT.getPayoffFunction(); assertEquals(payoff.getPayoff(DATA.withSpot(STRIKE + DIFF), LOW_PRICE), LOW_PRICE, EPS); assertEquals(payoff.getPayoff(DATA.withSpot(STRIKE - DIFF), LOW_PRICE), DIFF, EPS); assertEquals(payoff.getPayoff(DATA.withSpot(STRIKE + DIFF), HIGH_PRICE), HIGH_PRICE, EPS); assertEquals(payoff.getPayoff(DATA.withSpot(STRIKE - DIFF), HIGH_PRICE), HIGH_PRICE, EPS); }