final Object dataObject = inputs.getValue(ValueRequirementNames.CURVE_MARKET_DATA);
if (dataObject == null) {
throw new OpenGammaRuntimeException("Could not get yield curve data");
}
final InterpolatedCurveSpecification specification = (InterpolatedCurveSpecification) specificationObject;
final SnapshotDataBundle marketData = (SnapshotDataBundle) dataObject;
final int n = marketData.size();
final double[] times = new double[n];
final double[] yields = new double[n];
final double[][] jacobian = new double[n][n];
Boolean isYield = null;
int i = 0;
for (final CurveNodeWithIdentifier node : specification.getNodes()) {
if (node.getCurveNode() instanceof ContinuouslyCompoundedRateNode) {
if (i == 0) {
isYield = true;
} else {
if (!isYield) {
throw new OpenGammaRuntimeException("Was expecting only continuously-compounded rate nodes; have " + node.getCurveNode());
}
}
} else if (node.getCurveNode() instanceof DiscountFactorNode) {
if (i == 0) {
isYield = false;
} else {
if (isYield) {
throw new OpenGammaRuntimeException("Was expecting only discount factor nodes; have " + node.getCurveNode());
}
}
} else {
throw new OpenGammaRuntimeException("Can only handle discount factor or continuously-compounded rate nodes; have " + node.getCurveNode());
}
//TODO add check to make sure it's only discounting or rate curve nodes
final Double marketValue = marketData.getDataPoint(node.getIdentifier());
final Tenor maturity = node.getCurveNode().getResolvedMaturity();
if (marketValue == null) {
throw new OpenGammaRuntimeException("Could not get market data for " + node);
}
times[i] = DateUtils.estimatedDuration(maturity.getPeriod()).toDays() / 365.0; //TODO check if this is correct