yields[0] = curveForeign.getInterestRate(nodeTimes[0]);
yields[1] = curveForeign.getInterestRate(nodeTimes[1]);
curveNode = YieldCurve.from(InterpolatedDoublesCurve.fromSorted(nodeTimes, yields, new LinearInterpolator1D()));
curveBumpedPlus = curveNode.withSingleShift(nodeTimes[1], deltaShift);
curveBumpedMinus = curveNode.withSingleShift(nodeTimes[1], -deltaShift);
final YieldCurveBundle curvesForeign = new YieldCurveBundle();
curvesForeign.setCurve(bumpedCurveName, curveBumpedPlus);
curvesForeign.setCurve(CURVES_NAME[1], CURVES.getCurve(CURVES_NAME[1]));
dfForeignBumped = curveBumpedPlus.getDiscountFactor(forexForward.getPaymentTime());
forwardBumped = SPOT * dfForeignBumped / dfDomestic;
dMBumped = Math.log(forwardBumped / strike) / sigmaRootT - 0.5 * sigmaRootT;
final double bumpedPvForeignPlus = Math.abs(forexOptionCall.getUnderlyingForex().getPaymentCurrency2().getAmount()) * dfDomestic * NORMAL.getCDF(omega * dMBumped) * (isLong ? 1.0 : -1.0);
dfForeignBumped = curveBumpedMinus.getDiscountFactor(forexForward.getPaymentTime());
forwardBumped = SPOT * dfForeignBumped / dfDomestic;
dMBumped = Math.log(forwardBumped / strike) / sigmaRootT - 0.5 * sigmaRootT;
final double bumpedPvForeignMinus = Math.abs(forexOptionCall.getUnderlyingForex().getPaymentCurrency2().getAmount()) * dfDomestic * NORMAL.getCDF(omega * dMBumped) * (isLong ? 1.0 : -1.0);
final double resultForeign = (bumpedPvForeignPlus - bumpedPvForeignMinus) / (2 * deltaShift);
assertEquals("Forex Digital option: curve sensitivity", forexForward.getPaymentTime(), sensi.getSensitivity(USD).getSensitivities().get(CURVES_NAME[0]).get(0).first, TOLERANCE_TIME);
assertEquals("Forex Digital option: curve sensitivity", resultForeign, sensi.getSensitivity(USD).getSensitivities().get(CURVES_NAME[0]).get(0).second, TOLERANCE_DELTA);
//Domestic
yields[0] = curveDomestic.getInterestRate(nodeTimes[0]);
yields[1] = curveDomestic.getInterestRate(nodeTimes[1]);
curveNode = YieldCurve.from(InterpolatedDoublesCurve.fromSorted(nodeTimes, yields, new LinearInterpolator1D()));
curveBumpedPlus = curveNode.withSingleShift(nodeTimes[1], deltaShift);
curveBumpedMinus = curveNode.withSingleShift(nodeTimes[1], -deltaShift);
final YieldCurveBundle curvesDomestic = new YieldCurveBundle();
curvesDomestic.setCurve(CURVES_NAME[0], CURVES.getCurve(CURVES_NAME[0]));
curvesDomestic.setCurve(bumpedCurveName, curveBumpedPlus);
dfDomesticBumped = curveBumpedPlus.getDiscountFactor(forexForward.getPaymentTime());
forwardBumped = SPOT * dfForeign / dfDomesticBumped;
dMBumped = Math.log(forwardBumped / strike) / sigmaRootT - 0.5 * sigmaRootT;
final double bumpedPvDomesticPlus = Math.abs(forexOptionCall.getUnderlyingForex().getPaymentCurrency2().getAmount()) * dfDomesticBumped * NORMAL.getCDF(omega * dMBumped) * (isLong ? 1.0 : -1.0);
curvesForeign.replaceCurve(bumpedCurveName, curveBumpedMinus);