FadeInOptionDefinition extends OptionDefinition { @SuppressWarnings("unchecked") @Override public OptionPayoffFunction<StandardOptionWithSpotTimeSeriesDataBundle> getPayoffFunction() { return _payoffFunction; } FadeInOptionDefinition(final double strike, final Expiry expiry, final boolean isCall, final double lowerBound, final double upperBound); double getLowerBound(); double getUpperBound(); @Override int hashCode(); @Override boolean equals(final Object obj); @SuppressWarnings("unchecked") @Override OptionExerciseFunction<StandardOptionWithSpotTimeSeriesDataBundle> getExerciseFunction(); @SuppressWarnings("unchecked") @Override OptionPayoffFunction<StandardOptionWithSpotTimeSeriesDataBundle> getPayoffFunction();  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testPayoffWithNullDataBundle() { CALL.getPayoffFunction().getPayoff(null, null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testPayoffWithNullTS() { CALL.getPayoffFunction().getPayoff(new StandardOptionWithSpotTimeSeriesDataBundle(DATA, null), null); }
@Test public void testPayoff() { final double eps = 1e-15; OptionPayoffFunction<StandardOptionWithSpotTimeSeriesDataBundle> payoff = CALL.getPayoffFunction(); assertEquals(payoff.getPayoff(ALL_DATA.withSpot(SPOT - 1), null), 0, eps); assertEquals(payoff.getPayoff(ALL_DATA.withSpot(SPOT + 1), null), 1, eps); assertEquals(payoff.getPayoff(ONE_DATA.withSpot(SPOT - 1), null), 0, eps); assertEquals(payoff.getPayoff(ONE_DATA.withSpot(SPOT + 1), null), 0.2, eps); payoff = PUT.getPayoffFunction(); assertEquals(payoff.getPayoff(ALL_DATA.withSpot(SPOT - 1), null), 1, eps); assertEquals(payoff.getPayoff(ALL_DATA.withSpot(SPOT + 1), null), 0, eps); assertEquals(payoff.getPayoff(ONE_DATA.withSpot(SPOT - 1), null), 0.2, eps); assertEquals(payoff.getPayoff(ONE_DATA.withSpot(SPOT + 1), null), 0, eps); }