DATA_CHECKER.checkSpreadData(valuationDate, marketTenors, marketSpreads);
final Double[] yields = yieldCurve.getCurve().getYData();
final int nYields = yields.length;
final double[] bumpedYields = new double[nYields];
final double[] bucketedIR01 = new double[nYields];
ISDAYieldCurveAndSpreadsProvider calibrationData = new ISDAYieldCurveAndSpreadsProvider(marketTenors, marketSpreads, yieldCurve);
HazardRateCurve hazardRateCurve = HAZARD_RATE_CALCULATOR.calibrateHazardRateCurve(cds, calibrationData, valuationDate);
ISDAYieldCurveAndHazardRateCurveProvider curveProvider = new ISDAYieldCurveAndHazardRateCurveProvider(yieldCurve, hazardRateCurve);
final double presentValue = PV_CALCULATOR.getPresentValue(cds, curveProvider, valuationDate, priceType);
for (int i = 0; i < nYields; i++) {
bumpedYields[i] = yields[i];
}
final double bumpInBp = yieldBump / 10000;
switch(yieldBumpType) {
case ADDITIVE:
{
bumpedYields[0] += bumpInBp;
ISDADateCurve bumpedYieldCurve = new ISDADateCurve("Bumped", yieldCurve.getCurveDates(), yieldCurve.getTimePoints(), bumpedYields, yieldCurve.getOffset());
calibrationData = new ISDAYieldCurveAndSpreadsProvider(marketTenors, marketSpreads, bumpedYieldCurve);
hazardRateCurve = HAZARD_RATE_CALCULATOR.calibrateHazardRateCurve(cds, calibrationData, valuationDate);
curveProvider = new ISDAYieldCurveAndHazardRateCurveProvider(bumpedYieldCurve, hazardRateCurve);
double bumpedPresentValue = PV_CALCULATOR.getPresentValue(cds, curveProvider, valuationDate, priceType);
bucketedIR01[0] = (bumpedPresentValue - presentValue) / yieldBump;
for (int i = 1; i < nYields; i++) {
bumpedYields[i - 1] -= bumpInBp;
bumpedYields[i] += bumpInBp;
bumpedYieldCurve = new ISDADateCurve("Bumped", yieldCurve.getCurveDates(), yieldCurve.getTimePoints(), bumpedYields, yieldCurve.getOffset());
calibrationData = new ISDAYieldCurveAndSpreadsProvider(marketTenors, marketSpreads, bumpedYieldCurve);
hazardRateCurve = HAZARD_RATE_CALCULATOR.calibrateHazardRateCurve(cds, calibrationData, valuationDate);
curveProvider = new ISDAYieldCurveAndHazardRateCurveProvider(bumpedYieldCurve, hazardRateCurve);
bumpedPresentValue = PV_CALCULATOR.getPresentValue(cds, curveProvider, valuationDate, priceType);
bucketedIR01[i] = (bumpedPresentValue - presentValue) / yieldBump;
}
break;
}
case MULTIPLICATIVE:
bumpedYields[0] *= 1 + bumpInBp;
ISDADateCurve bumpedYieldCurve = new ISDADateCurve("Bumped", yieldCurve.getCurveDates(), yieldCurve.getTimePoints(), bumpedYields, yieldCurve.getOffset());
calibrationData = new ISDAYieldCurveAndSpreadsProvider(marketTenors, marketSpreads, bumpedYieldCurve);
hazardRateCurve = HAZARD_RATE_CALCULATOR.calibrateHazardRateCurve(cds, calibrationData, valuationDate);
curveProvider = new ISDAYieldCurveAndHazardRateCurveProvider(bumpedYieldCurve, hazardRateCurve);
double bumpedPresentValue = PV_CALCULATOR.getPresentValue(cds, curveProvider, valuationDate, priceType);
bucketedIR01[0] = (bumpedPresentValue - presentValue) / yieldBump;
for (int i = 1; i < nYields; i++) {
bumpedYields[i - 1] /= 1 + bumpInBp;
bumpedYields[i] *= 1 + bumpInBp;
bumpedYieldCurve = new ISDADateCurve("Bumped", yieldCurve.getCurveDates(), yieldCurve.getTimePoints(), bumpedYields, yieldCurve.getOffset());
calibrationData = new ISDAYieldCurveAndSpreadsProvider(marketTenors, marketSpreads, bumpedYieldCurve);
hazardRateCurve = HAZARD_RATE_CALCULATOR.calibrateHazardRateCurve(cds, calibrationData, valuationDate);
curveProvider = new ISDAYieldCurveAndHazardRateCurveProvider(bumpedYieldCurve, hazardRateCurve);
bumpedPresentValue = PV_CALCULATOR.getPresentValue(cds, curveProvider, valuationDate, priceType);
bucketedIR01[i] = (bumpedPresentValue - presentValue) / yieldBump;
}