AsymmetricPowerOptionDefinition extends OptionDefinition { @Override public OptionPayoffFunction<StandardOptionDataBundle> getPayoffFunction() { return _payoffFunction; } AsymmetricPowerOptionDefinition(final double strike, final Expiry expiry, final double power, final boolean isCall); double getPower(); @Override OptionExerciseFunction<StandardOptionDataBundle> getExerciseFunction(); @Override OptionPayoffFunction<StandardOptionDataBundle> getPayoffFunction(); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullDataBundle() { CALL.getPayoffFunction().getPayoff(null, null); }
@Test public void testPayoff() { final double eps = 1e-15; OptionPayoffFunction<StandardOptionDataBundle> payoff = CALL.getPayoffFunction(); assertEquals(payoff.getPayoff(DATA.withSpot(STRIKE - DIFF), 0.), 0, eps); assertEquals(payoff.getPayoff(DATA.withSpot(STRIKE + DIFF), 0.), Math.pow(STRIKE + DIFF, POWER) - STRIKE, eps); payoff = PUT.getPayoffFunction(); assertEquals(payoff.getPayoff(DATA.withSpot(STRIKE + DIFF), 0.), 0, eps); assertEquals(payoff.getPayoff(DATA.withSpot(STRIKE - DIFF), 0.), STRIKE - Math.pow(STRIKE - DIFF, POWER), eps); }