final Object baseQuotePairsObject = inputs.getValue(ValueRequirementNames.CURRENCY_PAIRS);
if (baseQuotePairsObject == null) {
throw new OpenGammaRuntimeException("Could not get base/quote pair data");
}
final CurrencyPairs baseQuotePairs = (CurrencyPairs) baseQuotePairsObject;
final CurrencyPair baseQuotePair = baseQuotePairs.getCurrencyPair(putCurrency, callCurrency);
if (baseQuotePair == null) {
throw new OpenGammaRuntimeException("Could not get base/quote pair for currency pair (" + putCurrency + ", " + callCurrency + ")");
}
if (baseQuotePair.getBase().equals(putCurrency)) { // To get Base/quote in market standard order.
ccy1 = putCurrency;
ccy2 = callCurrency;
curves = new YieldAndDiscountCurve[] {putFundingCurve, callFundingCurve };
allCurveNames = new String[] {fullPutCurveName, fullCallCurveName };
} else {
curves = new YieldAndDiscountCurve[] {callFundingCurve, putFundingCurve };
allCurveNames = new String[] {fullCallCurveName, fullPutCurveName };
ccy1 = callCurrency;
ccy2 = putCurrency;
}
final ForexSecurityConverter converter = new ForexSecurityConverter(baseQuotePairs);
final InstrumentDefinition<InstrumentDerivative> definition = (InstrumentDefinition<InstrumentDerivative>) security.accept(converter);
final InstrumentDerivative fxOption = definition.toDerivative(now, allCurveNames);
final YieldCurveBundle yieldCurves = new YieldCurveBundle(allCurveNames, curves);
final Object spotObject = inputs.getValue(ValueRequirementNames.SPOT_RATE);
if (spotObject == null) {
throw new OpenGammaRuntimeException("Could not get spot requirement");
}
double spot = (Double) spotObject;
if (baseQuotePair.getBase().equals(callCurrency)) { // To get Base/quote in market standard order.
spot = 1. / spot;
}
final ValueRequirement fxVolatilitySurfaceRequirement = getSurfaceRequirement(surfaceName, putCurrency, callCurrency, interpolatorName, leftExtrapolatorName, rightExtrapolatorName);
final Object volatilitySurfaceObject = inputs.getValue(fxVolatilitySurfaceRequirement);
if (volatilitySurfaceObject == null) {