SensitivityPnLCalculator implements Function<SensitivityAndReturnDataBundle, DoubleTimeSeries<?>> { @Override public DoubleTimeSeries<?> evaluate(final SensitivityAndReturnDataBundle... data) { Validate.notNull(data, "data"); DoubleTimeSeries<?> result = null; DoubleTimeSeries<?> pnl = null; for (final SensitivityAndReturnDataBundle bundle : data) { final Underlying underlying = bundle.getUnderlying(); final Map<UnderlyingType, DoubleTimeSeries<?>> underlyingData = bundle.getUnderlyingReturnTS(); if (result == null) { result = TaylorExpansionMultiplierCalculator.getTimeSeries(underlyingData, underlying); result = result.multiply(bundle.getValue()); } else { pnl = TaylorExpansionMultiplierCalculator.getTimeSeries(underlyingData, underlying); result = result.add(pnl.multiply(bundle.getValue())); } } return result; }  @Override DoubleTimeSeries<?> evaluate(final SensitivityAndReturnDataBundle... data);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullData() { CALCULATOR.evaluate((SensitivityAndReturnDataBundle[]) null); }
@Test public void test() { final DoubleTimeSeries<?> ts = CALCULATOR.evaluate(DATA); final PreciseDoubleTimeSeries<?> pnl = (PreciseDoubleTimeSeries<?>) ts; assertEquals(pnl.getTimeAtIndexFast(0), TIMES[0]); assertEquals(pnl.getTimeAtIndexFast(1), TIMES[1]); assertEquals(pnl.getValueAtIndexFast(0), 680.5, 1e-9); assertEquals(pnl.getValueAtIndexFast(1), 775.875, 1e-9); }