@Deprecated
public class ForexLocalVolatilityPDEGridPresentValueFunction extends AbstractFunction.NonCompiledInvoker {
@Override
public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
final FXOptionSecurity fxOption = (FXOptionSecurity) target.getSecurity();
final ValueRequirement desiredValue = desiredValues.iterator().next();
final String surfaceName = desiredValue.getConstraint(SURFACE);
final String surfaceType = desiredValue.getConstraint(PROPERTY_SURFACE_TYPE);
final String xAxis = desiredValue.getConstraint(PROPERTY_X_AXIS);
final String yAxis = desiredValue.getConstraint(PROPERTY_Y_AXIS);
final String yAxisType = desiredValue.getConstraint(PROPERTY_Y_AXIS_TYPE);
final String forwardCurveCalculationMethod = desiredValue.getConstraint(CURVE_CALCULATION_METHOD);
final String forwardCurveName = desiredValue.getConstraint(CURVE);
final String h = desiredValue.getConstraint(PROPERTY_H);
final String theta = desiredValue.getConstraint(PROPERTY_THETA);
final String timeSteps = desiredValue.getConstraint(PROPERTY_TIME_STEPS);
final String spaceSteps = desiredValue.getConstraint(PROPERTY_SPACE_STEPS);
final String timeGridBunching = desiredValue.getConstraint(PROPERTY_TIME_GRID_BUNCHING);
final String spaceGridBunching = desiredValue.getConstraint(PROPERTY_SPACE_GRID_BUNCHING);
final String maxMoneyness = desiredValue.getConstraint(PROPERTY_MAX_MONEYNESS);
final String pdeDirection = desiredValue.getConstraint(PROPERTY_PDE_DIRECTION);
if (!(pdeDirection.equals(LocalVolatilityPDEValuePropertyNames.FORWARD_PDE))) {
throw new OpenGammaRuntimeException("Can only use forward PDE; should never ask for this direction: " + pdeDirection);
}
final Object greekObject = inputs.getValue(getGreekRequirement(target, surfaceName, surfaceType, xAxis, yAxis, yAxisType,
forwardCurveCalculationMethod, forwardCurveName, theta, timeSteps, spaceSteps, timeGridBunching, spaceGridBunching, maxMoneyness, h, pdeDirection));
if (greekObject == null) {
throw new OpenGammaRuntimeException("Could not get greeks");
}
final PDEResultCollection greeks = (PDEResultCollection) greekObject;
final Object spotFXObject = inputs.getValue(getSpotRequirement(fxOption));
if (spotFXObject == null) {
throw new OpenGammaRuntimeException("Could not get spot FX");
}
final double[] strikes = greeks.getStrikes();
final double[] lvPutPips = greeks.getGridGreeks(PDEResultCollection.GRID_PRICE);
final double[] blackPutPips = greeks.getGridGreeks(PDEResultCollection.GRID_BLACK_PRICE);
final double spotFX = (Double) spotFXObject;
final Currency putCurrency = fxOption.getPutCurrency();
final Currency callCurrency = fxOption.getCallCurrency();
final double putAmount = fxOption.getPutAmount();
final double callAmount = fxOption.getCallAmount();
final ForexLocalVolatilityPDEPresentValueResultCollection result = new ForexLocalVolatilityPDEPresentValueResultCollection(strikes, lvPutPips, blackPutPips, spotFX,
putCurrency, callCurrency, putAmount, callAmount);
final ValueProperties properties = createValueProperties()
.with(ValuePropertyNames.CALCULATION_METHOD, LocalVolatilityPDEValuePropertyNames.LOCAL_VOLATILITY_METHOD)
.with(InstrumentTypeProperties.PROPERTY_SURFACE_INSTRUMENT_TYPE, InstrumentTypeProperties.FOREX)