EuropeanExchangeAssetOptionDefinition extends OptionDefinition { @SuppressWarnings("unchecked") @Override public OptionPayoffFunction<StandardTwoAssetOptionDataBundle> getPayoffFunction() { return _payoffFunction; } EuropeanExchangeAssetOptionDefinition(final Expiry expiry, final double firstQuantity, final double secondQuantity); double getFirstQuantity(); double getSecondQuantity(); @SuppressWarnings("unchecked") @Override OptionExerciseFunction<StandardTwoAssetOptionDataBundle> getExerciseFunction(); @SuppressWarnings("unchecked") @Override OptionPayoffFunction<StandardTwoAssetOptionDataBundle> getPayoffFunction(); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test public void testPayoffFunction() { final double eps = 1e-15; final double q1 = 1.2; final double q2 = 1; final EuropeanExchangeAssetOptionDefinition option = new EuropeanExchangeAssetOptionDefinition(EXPIRY, q1, q2); StandardTwoAssetOptionDataBundle data = new StandardTwoAssetOptionDataBundle(DATA); assertEquals(option.getPayoffFunction().getPayoff(data, 0.), 0, eps); data = DATA.withFirstSpot(110); assertEquals(option.getPayoffFunction().getPayoff(data, 0.), 12, eps); data = DATA.withFirstSpot(80); assertEquals(option.getPayoffFunction().getPayoff(data, 0.), 0, eps); data = DATA.withSecondSpot(130); assertEquals(option.getPayoffFunction().getPayoff(data, 0.), 0, eps); data = DATA.withSecondSpot(110); assertEquals(option.getPayoffFunction().getPayoff(data, 0.), 10, eps); }