final LocalDateDoubleTimeSeries[] returnSeries = new LocalDateDoubleTimeSeries[n];
final HistoricalTimeSeriesBundle tsBundle = (HistoricalTimeSeriesBundle) inputs.getValue(CURVE_HISTORICAL_TIME_SERIES);
final Iterator<CurveNodeWithIdentifier> iterator = curveSpec.getNodes().iterator();
for (int i = 0; i < n; i++) {
final double sensitivity = fcns[i];
final CurveNodeWithIdentifier curveNode = iterator.next();
final HistoricalTimeSeries ts = tsBundle.get(curveNode.getDataField(), curveNode.getIdentifier());
if (ts == null) {
throw new OpenGammaRuntimeException("Could not get time series for id " + curveNode.getIdentifier() + " and data field " + curveNode.getDataField());
}
LocalDateDoubleTimeSeries pnlSeries;
if (curveNode instanceof PointsCurveNodeWithIdentifier) {
final PointsCurveNodeWithIdentifier pointsCurveNode = (PointsCurveNodeWithIdentifier) curveNode;
final HistoricalTimeSeries underlyingSeries = tsBundle.get(pointsCurveNode.getUnderlyingDataField(), pointsCurveNode.getUnderlyingIdentifier());
if (underlyingSeries == null) {
throw new OpenGammaRuntimeException("Could not get time series for id " + pointsCurveNode.getUnderlyingIdentifier() + " and data field " + pointsCurveNode.getUnderlyingDataField());
}
pnlSeries = getReturnSeries(ts.getTimeSeries().add(underlyingSeries.getTimeSeries()), desiredValue, executionContext);
} else {
pnlSeries = getReturnSeries(ts.getTimeSeries(), desiredValue, executionContext);
}
tenors[i] = curveNode.getCurveNode().getResolvedMaturity();
returnSeries[i] = pnlSeries.multiply(sensitivity * position.getQuantity().doubleValue());
}
final TenorLabelledLocalDateDoubleTimeSeriesMatrix1D matrix = new TenorLabelledLocalDateDoubleTimeSeriesMatrix1D(tenors, labels, returnSeries);
final ValueProperties properties = desiredValue.getConstraints().copy()
.withoutAny(CURRENCY)