// Compute present value under current market
final double pvBase = irFutureOption.accept(s_pvCalculator, market);
// Form market scenario
final YieldCurveWithBlackCubeBundle marketScen;
ValueProperties constraints = desiredValues.iterator().next().getConstraints();
// Apply shift to yield curve(s)
final YieldCurveBundle curvesScen = new YieldCurveBundle();
String priceShiftTypeConstraint = constraints.getValues(s_priceShiftType).iterator().next();
String priceConstraint = constraints.getValues(s_priceShift).iterator().next();
if (priceConstraint.equals("")) {
// use base market prices
curvesScen.addAll(market);
} else {
final Double shift = Double.valueOf(priceConstraint);
// As curve may be functional, we can only apply a parallel shift.
Double parallelShift;
for (String crvName : market.getAllNames()) {
YieldAndDiscountCurve curve = market.getCurve(crvName);
if (priceShiftTypeConstraint.equalsIgnoreCase("Additive")) {
parallelShift = shift;
} else {
if (!(priceShiftTypeConstraint.equalsIgnoreCase("Multiplicative"))) {
s_logger.debug("Valid PriceShiftType's: Additive and Multiplicative. Found: " + priceShiftTypeConstraint + " Defaulting to Multiplicative.");
}
// We (arbitrarily) choose to scale by the rate at the short end
double shortRate = curve.getInterestRate(0.0);
parallelShift = shift * shortRate;
}
YieldAndDiscountCurve curveShifted = curve.withParallelShift(parallelShift);
curvesScen.setCurve(crvName, curveShifted);
}
}
// Apply shift to vol surface
String volConstraint = constraints.getValues(s_volShift).iterator().next();
if (volConstraint.equals("")) {
// use base market vols
marketScen = market;
} else {
// bump vol surface
final Double shiftVol = Double.valueOf(volConstraint);
String volShiftTypeConstraint = constraints.getValues(s_volShiftType).iterator().next();
final boolean additiveShift;
if (volShiftTypeConstraint.equalsIgnoreCase("Additive")) {
additiveShift = true;
} else if (volShiftTypeConstraint.equalsIgnoreCase("Multiplicative")) {
additiveShift = false;
} else {
s_logger.debug("In ScenarioPnLFunctions, VolShiftType's are Additive and Multiplicative. Found: " + priceShiftTypeConstraint + " Defaulting to Multiplicative.");
additiveShift = false;
}
final Surface<Double, Double, Double> volSurfaceScen = SurfaceShiftFunctionFactory.getShiftedSurface(market.getBlackParameters(), shiftVol, additiveShift);
marketScen = new YieldCurveWithBlackCubeBundle(volSurfaceScen, curvesScen);
}
// Compute present value under scenario
final double pvScen = irFutureOption.accept(s_pvCalculator, marketScen);