BermudanOptionFunctionProvider extends OptionFunctionProvider1D { public double[] getExerciseTimes() { return _exerciseTimes; } BermudanOptionFunctionProvider(final double strike, final double timeToExpiry, final int steps, final boolean isCall, final double[] exerciseTimes); @Override double[] getPayoffAtExpiry(final double assetPrice, final double downFactor, final double upOverDown); @Override double[] getNextOptionValues(final double discount, final double upProbability, final double downProbability, final double[] values, final double baseAssetPrice, final double sumCashDiv,
      final double downFactor, final double upOverDown, final int steps); @Override double[] getPayoffAtExpiryTrinomial(final double assetPrice, final double downFactor, final double middleOverDown); @Override double[] getNextOptionValues(final double discount, final double upProbability, final double middleProbability, final double downProbability, final double[] values,
      final double baseAssetPrice, final double sumCashDiv, final double downFactor, final double middleOverDown, final int steps); int getNumberOfExerciseTimes(); double[] getExerciseTimes(); int[] getExerciseSteps(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void getExerciseTimesTest() { final int steps = 1253; final double dt = TIME / steps; final double eps = dt * 0.1; final int[] expectedSteps = new int[] {3, 349, 21, 1143 }; final double[] exerciseTimes = new double[] {dt * expectedSteps[0] + eps, dt * expectedSteps[2] - eps, dt * expectedSteps[1] - 3. * eps, dt * expectedSteps[3] }; final int nTimes = exerciseTimes.length; final BermudanOptionFunctionProvider function = new BermudanOptionFunctionProvider(100., TIME, steps, true, exerciseTimes); Arrays.sort(expectedSteps); Arrays.sort(exerciseTimes); assertEquals(function.getNumberOfExerciseTimes(), nTimes); for (int i = 0; i < nTimes; ++i) { assertEquals(function.getExerciseSteps()[i], expectedSteps[i]); assertEquals(function.getExerciseTimes()[i], exerciseTimes[i], 1.e-14); } }