@Test
public void test() {
DoubleTimeSeries<?> ts = ImmutableZonedDateTimeDoubleTimeSeries.ofUTC(new ZonedDateTime[] {DateUtils.getUTCDate(2010, 6, 1), DateUtils.getUTCDate(2010, 11, 1)}, new double[] {SPOT, 100});
StandardOptionWithSpotTimeSeriesDataBundle data = new StandardOptionWithSpotTimeSeriesDataBundle(CURVE, B, new VolatilitySurface(ConstantDoublesSurface.from(0.15)), SPOT, DATE, ts);
ExtremeSpreadOptionDefinition option = new ExtremeSpreadOptionDefinition(EXPIRY, true, new Expiry(DateUtils.getDateOffsetWithYearFraction(DATE, 0.25)), false);
assertEquals(MODEL.getPricingFunction(option).evaluate(data), 10.6618, EPS);
ts = ImmutableZonedDateTimeDoubleTimeSeries.ofUTC(new ZonedDateTime[] {DateUtils.getUTCDate(2010, 6, 1), DateUtils.getUTCDate(2010, 11, 1)}, new double[] {SPOT, 110});
data = data.withSpotTimeSeries(ts);
assertEquals(MODEL.getPricingFunction(option).evaluate(data), 8.4878, EPS);
ts = ImmutableZonedDateTimeDoubleTimeSeries.ofUTC(new ZonedDateTime[] {DateUtils.getUTCDate(2010, 6, 1), DateUtils.getUTCDate(2010, 11, 1)}, new double[] {SPOT, 120});
data = data.withSpotTimeSeries(ts);
assertEquals(MODEL.getPricingFunction(option).evaluate(data), 4.5235, EPS);
option = new ExtremeSpreadOptionDefinition(EXPIRY, true, new Expiry(DateUtils.getDateOffsetWithYearFraction(DATE, 0.75)), true);
data = data.withVolatilitySurface(new VolatilitySurface(ConstantDoublesSurface.from(0.3)));
ts = ImmutableZonedDateTimeDoubleTimeSeries.ofUTC(new ZonedDateTime[] {DateUtils.getUTCDate(2010, 6, 1), DateUtils.getUTCDate(2010, 11, 1)}, new double[] {SPOT, 100});
data = data.withSpotTimeSeries(ts);
assertEquals(MODEL.getPricingFunction(option).evaluate(data), 13.3404, EPS);
ts = ImmutableZonedDateTimeDoubleTimeSeries.ofUTC(new ZonedDateTime[] {DateUtils.getUTCDate(2010, 6, 1), DateUtils.getUTCDate(2010, 11, 1)}, new double[] {SPOT, 90});
data = data.withSpotTimeSeries(ts);
assertEquals(MODEL.getPricingFunction(option).evaluate(data), 14.8173, EPS);
ts = ImmutableZonedDateTimeDoubleTimeSeries.ofUTC(new ZonedDateTime[] {DateUtils.getUTCDate(2010, 6, 1), DateUtils.getUTCDate(2010, 11, 1)}, new double[] {SPOT, 80});
data = data.withSpotTimeSeries(ts);
assertEquals(MODEL.getPricingFunction(option).evaluate(data), 19.0537, EPS);
option = new ExtremeSpreadOptionDefinition(EXPIRY, true, new Expiry(DateUtils.getDateOffsetWithYearFraction(DATE, 0.)), true);
ts = ImmutableZonedDateTimeDoubleTimeSeries.ofUTC(new ZonedDateTime[] {DateUtils.getUTCDate(2010, 6, 1), DateUtils.getUTCDate(2010, 11, 1)}, new double[] {SPOT, 100});
data = data.withSpotTimeSeries(ts);
assertEquals(MODEL.getPricingFunction(option).evaluate(data), 0, EPS);
ts = ImmutableZonedDateTimeDoubleTimeSeries.ofUTC(new ZonedDateTime[] {DateUtils.getUTCDate(2010, 6, 1), DateUtils.getUTCDate(2010, 11, 1)}, new double[] {SPOT, 90});
data = data.withSpotTimeSeries(ts);