final double[] sensitivity = new double[nbNodePoint];
for (int loopnode = 0; loopnode < nbNodePoint; loopnode++) {
final double[] yieldBumpedPlus = curveInt.getYDataAsPrimitive().clone();
yieldBumpedPlus[loopnode] += _shift;
final YieldAndDiscountCurve dscBumpedPlus = new YieldCurve(curveInt.getName(), new InterpolatedDoublesCurve(curveInt.getXDataAsPrimitive(), yieldBumpedPlus, curveInt.getInterpolator(), true));
final MulticurveProviderDiscount marketDscBumpedPlus = multicurve.withDiscountFactor(ccy, dscBumpedPlus);
final Double valueBumpedPlus = instrument.accept(_valueCalculator, marketDscBumpedPlus);
final double[] yieldBumpedMinus = curveInt.getYDataAsPrimitive().clone();
yieldBumpedMinus[loopnode] -= _shift;
final YieldAndDiscountCurve dscBumpedMinus = new YieldCurve(curveInt.getName(), new InterpolatedDoublesCurve(curveInt.getXDataAsPrimitive(), yieldBumpedMinus,
curveInt.getInterpolator(), true));
final MulticurveProviderDiscount marketDscBumpedMinus = multicurve.withDiscountFactor(ccy, dscBumpedMinus);
final Double valueBumpedMinus = instrument.accept(_valueCalculator, marketDscBumpedMinus);
final Double valueDiff = valueBumpedPlus - valueBumpedMinus;
sensitivity[loopnode] = valueDiff / (2 * _shift);
}
final String name = multicurve.getName(ccy);
result = result.plus(name, new DoubleMatrix1D(sensitivity));
}
// Forward ON
final Set<IndexON> indexON = multicurve.getIndexesON();
for (final IndexON index : indexON) {
final YieldAndDiscountCurve curve = multicurve.getCurve(index);
ArgumentChecker.isTrue(curve instanceof YieldCurve, "Curve should be a YieldCurve");
final YieldCurve curveYield = (YieldCurve) curve;
ArgumentChecker.isTrue(curveYield.getCurve() instanceof InterpolatedDoublesCurve, "Yield curve should be based on InterpolatedDoublesCurve");
final InterpolatedDoublesCurve curveInt = (InterpolatedDoublesCurve) curveYield.getCurve();
final int nbNodePoint = curveInt.getXDataAsPrimitive().length;
final double[] sensitivity = new double[nbNodePoint];
for (int loopnode = 0; loopnode < nbNodePoint; loopnode++) {
final double[] yieldBumpedPlus = curveInt.getYDataAsPrimitive().clone();
yieldBumpedPlus[loopnode] += _shift;
final YieldAndDiscountCurve fwdBumpedPlus = new YieldCurve(curveInt.getName(), new InterpolatedDoublesCurve(curveInt.getXDataAsPrimitive(), yieldBumpedPlus, curveInt.getInterpolator(), true));
final MulticurveProviderDiscount marketFwdBumpedPlus = multicurve.withForward(index, fwdBumpedPlus);
final Double valueBumpedPlus = instrument.accept(_valueCalculator, marketFwdBumpedPlus);
final double[] yieldBumpedMinus = curveInt.getYDataAsPrimitive().clone();
yieldBumpedMinus[loopnode] -= _shift;
final YieldAndDiscountCurve fwdBumpedMinus = new YieldCurve(curveInt.getName(), new InterpolatedDoublesCurve(curveInt.getXDataAsPrimitive(), yieldBumpedMinus,
curveInt.getInterpolator(), true));
final MulticurveProviderDiscount marketFwdBumpedMinus = multicurve.withForward(index, fwdBumpedMinus);
final Double valueBumpedMinus = instrument.accept(_valueCalculator, marketFwdBumpedMinus);
final Double valueDiff = valueBumpedPlus - valueBumpedMinus;
sensitivity[loopnode] = valueDiff / (2 * _shift);
}
final String name = multicurve.getName(index);
result = result.plus(name, new DoubleMatrix1D(sensitivity));
}
// Forward Ibor - symmetrical
final Set<IborIndex> indexForward = multicurve.getIndexesIbor();
for (final IborIndex index : indexForward) {
final YieldAndDiscountCurve curve = multicurve.getCurve(index);
ArgumentChecker.isTrue(curve instanceof YieldCurve, "Curve should be a YieldCurve");
final YieldCurve curveYield = (YieldCurve) curve;
ArgumentChecker.isTrue(curveYield.getCurve() instanceof InterpolatedDoublesCurve, "Yield curve should be based on InterpolatedDoublesCurve");
final InterpolatedDoublesCurve curveInt = (InterpolatedDoublesCurve) curveYield.getCurve();
final int nbNodePoint = curveInt.getXDataAsPrimitive().length;
final double[] sensitivity = new double[nbNodePoint];
for (int loopnode = 0; loopnode < nbNodePoint; loopnode++) {
final double[] yieldBumpedPlus = curveInt.getYDataAsPrimitive().clone();
yieldBumpedPlus[loopnode] += _shift;
final YieldAndDiscountCurve fwdBumpedPlus = new YieldCurve(curveInt.getName(), new InterpolatedDoublesCurve(curveInt.getXDataAsPrimitive(), yieldBumpedPlus, curveInt.getInterpolator(), true));
final MulticurveProviderDiscount marketFwdBumpedPlus = multicurve.withForward(index, fwdBumpedPlus);
final Double valueBumpedPlus = instrument.accept(_valueCalculator, marketFwdBumpedPlus);
final double[] yieldBumpedMinus = curveInt.getYDataAsPrimitive().clone();
yieldBumpedMinus[loopnode] -= _shift;
final YieldAndDiscountCurve fwdBumpedMinus = new YieldCurve(curveInt.getName(), new InterpolatedDoublesCurve(curveInt.getXDataAsPrimitive(), yieldBumpedMinus,
curveInt.getInterpolator(), true));
final MulticurveProviderDiscount marketFwdBumpedMinus = multicurve.withForward(index, fwdBumpedMinus);
final Double valueBumpedMinus = instrument.accept(_valueCalculator, marketFwdBumpedMinus);
final Double valueDiff = valueBumpedPlus - valueBumpedMinus;
sensitivity[loopnode] = valueDiff / (2 * _shift);
}
final String name = multicurve.getName(index);