sensitivity[loopccypv][loopnode] = pvDiff.getAmount(ccyList.get(loopccypv)) / _shift;
}
}
final String name = issuercurves.getMulticurveProvider().getName(ccy);
for (int loopccypv = 0; loopccypv < nbCcy; loopccypv++) {
result = result.plus(new ObjectsPair<>(name, ccyList.get(loopccypv)), new DoubleMatrix1D(sensitivity[loopccypv]));
}
}
// Forward ON
final Set<IndexON> indexON = issuercurves.getMulticurveProvider().getIndexesON();
for (final IndexON index : indexON) {
final YieldAndDiscountCurve curve = issuercurves.getMulticurveProvider().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[nbCcy][nbNodePoint];
for (int loopnode = 0; loopnode < nbNodePoint; loopnode++) {
final double[] yieldBumped = curveInt.getYDataAsPrimitive().clone();
yieldBumped[loopnode] += _shift;
final YieldAndDiscountCurve fwdBumped = new YieldCurve(curveInt.getName(), new InterpolatedDoublesCurve(curveInt.getXDataAsPrimitive(), yieldBumped, curveInt.getInterpolator(), true));
final IssuerProviderDiscount marketFwdBumped = new IssuerProviderDiscount(issuercurves.getMulticurveProvider().withForward(index, fwdBumped), issuercurves.getIssuerCurves());
final MultipleCurrencyAmount pvBumped = instrument.accept(_valueCalculator, marketFwdBumped);
final MultipleCurrencyAmount pvDiff = pvBumped.plus(pvInitMinus);
for (int loopccypv = 0; loopccypv < nbCcy; loopccypv++) {
sensitivity[loopccypv][loopnode] = pvDiff.getAmount(ccyList.get(loopccypv)) / _shift;
}
}
final String name = issuercurves.getMulticurveProvider().getName(index);
for (int loopccypv = 0; loopccypv < nbCcy; loopccypv++) {
result = result.plus(new ObjectsPair<>(name, ccyList.get(loopccypv)), new DoubleMatrix1D(sensitivity[loopccypv]));
}
}
// Forward Ibor
final Set<IborIndex> indexForward = issuercurves.getMulticurveProvider().getIndexesIbor();
for (final IborIndex index : indexForward) {
final YieldAndDiscountCurve curve = issuercurves.getMulticurveProvider().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[nbCcy][nbNodePoint];
for (int loopnode = 0; loopnode < nbNodePoint; loopnode++) {
final double[] yieldBumped = curveInt.getYDataAsPrimitive().clone();
yieldBumped[loopnode] += _shift;
final YieldAndDiscountCurve fwdBumped = new YieldCurve(curveInt.getName(), new InterpolatedDoublesCurve(curveInt.getXDataAsPrimitive(), yieldBumped, curveInt.getInterpolator(), true));
final IssuerProviderDiscount marketFwdBumped = new IssuerProviderDiscount(issuercurves.getMulticurveProvider().withForward(index, fwdBumped), issuercurves.getIssuerCurves());
final MultipleCurrencyAmount pvBumped = instrument.accept(_valueCalculator, marketFwdBumped);
final MultipleCurrencyAmount pvDiff = pvBumped.plus(pvInitMinus);
for (int loopccypv = 0; loopccypv < nbCcy; loopccypv++) {
sensitivity[loopccypv][loopnode] = pvDiff.getAmount(ccyList.get(loopccypv)) / _shift;
}
}
final String name = issuercurves.getMulticurveProvider().getName(index);
for (int loopccypv = 0; loopccypv < nbCcy; loopccypv++) {
result = result.plus(new ObjectsPair<>(name, ccyList.get(loopccypv)), new DoubleMatrix1D(sensitivity[loopccypv]));
}
}
// Discounting issuer
final Set<Pair<String, Currency>> issuerCcies = issuercurves.getIssuersCurrencies();
for (final Pair<String, Currency> ic : issuerCcies) {
final YieldAndDiscountCurve curve = issuercurves.getCurve(ic);
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[nbCcy][nbNodePoint];
for (int loopnode = 0; loopnode < nbNodePoint; loopnode++) {
final double[] yieldBumped = curveInt.getYDataAsPrimitive().clone();
yieldBumped[loopnode] += _shift;
final YieldAndDiscountCurve icBumped = new YieldCurve(curveInt.getName(), new InterpolatedDoublesCurve(curveInt.getXDataAsPrimitive(), yieldBumped, curveInt.getInterpolator(), true));
final IssuerProvider providerIcBumped = issuercurves.withIssuerCurrency(ic, icBumped);
final MultipleCurrencyAmount pvBumped = instrument.accept(_valueCalculator, providerIcBumped);
final MultipleCurrencyAmount pvDiff = pvBumped.plus(pvInitMinus);
for (int loopccypv = 0; loopccypv < nbCcy; loopccypv++) {
sensitivity[loopccypv][loopnode] = pvDiff.getAmount(ccyList.get(loopccypv)) / _shift;
}
}
final String name = issuercurves.getName(ic);
for (int loopccypv = 0; loopccypv < nbCcy; loopccypv++) {
result = result.plus(new ObjectsPair<>(name, ccyList.get(loopccypv)), new DoubleMatrix1D(sensitivity[loopccypv]));
}
}
return result;
}