final CurrencyAmount result = forex.accept(CALCULATOR, data);
final double gammaValue = result.getAmount() / 100.0; // FIXME: the 100 should be removed when the scaling is available
// for PLAT-4626
double spot = 1;
if (forex instanceof ForexOptionVanilla) {
final ForexOptionVanilla fxDerivative = (ForexOptionVanilla) forex;
spot = data.getFxRates().getFxRate(fxDerivative.getCurrency1(), fxDerivative.getCurrency2());
} else if (forex instanceof ForexOptionDigital) {
final ForexOptionDigital fxDerivative = (ForexOptionDigital) forex;
if (fxDerivative.payDomestic()) {
spot = data.getFxRates().getFxRate(fxDerivative.getCurrency1(), fxDerivative.getCurrency2());
} else {
spot = data.getFxRates().getFxRate(fxDerivative.getCurrency2(), fxDerivative.getCurrency1());
}
} else if (forex instanceof ForexOptionSingleBarrier) {
final ForexOptionSingleBarrier fxDerivative = (ForexOptionSingleBarrier) forex;
spot = data.getFxRates().getFxRate(fxDerivative.getCurrency1(), fxDerivative.getCurrency2());
return Collections.singleton(new ComputedValue(spec, gammaValue * spot * spot));
}
return Collections.singleton(new ComputedValue(spec, gammaValue * spot));
}
throw new OpenGammaRuntimeException("Can only calculate gamma spot for surfaces with smiles");