ExcessContinuouslyCompoundedTimeSeriesReturnCalculator extends TimeSeriesReturnCalculator { @Override public LocalDateDoubleTimeSeries evaluate(final LocalDateDoubleTimeSeries... x) { Validate.notNull(x, "x"); if (x.length < 4) { throw new TimeSeriesException("Time series array must contain at least four elements"); } if (getMode() == CalculationMode.STRICT && x[0].size() != x[2].size()) { throw new TimeSeriesException("Asset price series and reference price series were not the same size"); } final LocalDateDoubleTimeSeries assetReturn = x[1] == null ? _returnCalculator.evaluate(x[0]) : _returnCalculator.evaluate(x[0], x[1]); final LocalDateDoubleTimeSeries referenceReturn = x[3] == null ? _returnCalculator.evaluate(x[2]) : _returnCalculator.evaluate(x[2], x[3]); return assetReturn.subtract(referenceReturn); } ExcessContinuouslyCompoundedTimeSeriesReturnCalculator(final CalculationMode mode); @Override LocalDateDoubleTimeSeries evaluate(final LocalDateDoubleTimeSeries... x);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullArray() { CALCULATOR.evaluate((LocalDateDoubleTimeSeries[]) null); }
@Test(expectedExceptions = TimeSeriesException.class) public void testSmallArray() { CALCULATOR.evaluate(new LocalDateDoubleTimeSeries[] {TS1, TS2}); }
@Test(expectedExceptions = TimeSeriesException.class) public void testDifferentLengths() { CALCULATOR.evaluate(new LocalDateDoubleTimeSeries[] {TS1, null, ImmutableLocalDateDoubleTimeSeries.of(new LocalDate[] { LocalDate.ofEpochDay(1) }, new double[] {1}), null}); }
@Test public void test() { assertEquals(CALCULATOR.evaluate(new LocalDateDoubleTimeSeries[] {TS1, EMPTY_SERIES, TS2, EMPTY_SERIES}), RETURNS .evaluate(TS1)); assertEquals(CALCULATOR.evaluate(new LocalDateDoubleTimeSeries[] {TS1, null, TS2, null}), RETURNS.evaluate(TS1)); }