}
} else {
throw new OpenGammaRuntimeException("Unexpected convention on inflation leg, expected an inflation leg convention");
}
final HistoricalTimeSeries historicalTimeSeries = timeSeries.get(node.getDataField(), priceIndexId);
if (historicalTimeSeries == null) {
throw new OpenGammaRuntimeException("Could not get price time series for " + priceIndexId);
}
final DoubleTimeSeries<?> ts = historicalTimeSeries.getTimeSeries();
if (ts == null) {
throw new OpenGammaRuntimeException("Could not get price time series for " + priceIndexId);
}
final int length = ts.size();
if (length == 0) {
throw new OpenGammaRuntimeException("Price time series for " + priceIndexId + " was empty");
}
final ZonedDateTimeDoubleTimeSeries multiply = convertTimeSeries(ZoneId.of("UTC"), (LocalDateDoubleTimeSeries) ts.multiply(100));
return ((InstrumentDefinitionWithData<?, ZonedDateTimeDoubleTimeSeries[]>) definition).toDerivative(
now,
new ZonedDateTimeDoubleTimeSeries[] {multiply, multiply});
}
if (node.getCurveNode() instanceof RateFutureNode || node.getCurveNode() instanceof DeliverableSwapFutureNode) {
ArgumentChecker.notNull(timeSeries, "time series");
final ExternalId id = node.getIdentifier();
final HistoricalTimeSeries historicalTimeSeries = timeSeries.get(node.getDataField(), id);
if (historicalTimeSeries == null) {
if (node.getCurveNode() instanceof DeliverableSwapFutureNode) {
final double lastMarginPrice = 0.99;
return ((InstrumentDefinitionWithData<?, Double>) definition).toDerivative(now, lastMarginPrice);
}
throw new OpenGammaRuntimeException("Could not get price time series for " + id);
}
final DoubleTimeSeries<?> ts = historicalTimeSeries.getTimeSeries();
if (ts == null) {
throw new OpenGammaRuntimeException("Could not get price time series for " + id);
}
final int length = ts.size();
if (length == 0) {
throw new OpenGammaRuntimeException("Price time series for " + id + " was empty");
}
if (definition instanceof FederalFundsFutureTransactionDefinition) {
final DoubleTimeSeries<ZonedDateTime>[] tsArray = new DoubleTimeSeries[2];
tsArray[0] = convertTimeSeries(now.getZone(), historicalTimeSeries.getTimeSeries());
return ((InstrumentDefinitionWithData<?, DoubleTimeSeries<ZonedDateTime>[]>) definition).toDerivative(now, tsArray); //CSIGNORE
}
final double lastMarginPrice = ts.getLatestValue();
return ((InstrumentDefinitionWithData<?, Double>) definition).toDerivative(now, lastMarginPrice);
}