/** * Copyright (C) 2012 - present by OpenGamma Inc. and the OpenGamma group of companies * * Please see distribution for license. */ package com.opengamma.financial.analytics.model.pnl; import java.util.Collections; import java.util.Set; import com.opengamma.engine.ComputationTarget; import com.opengamma.engine.function.FunctionCompilationContext; import com.opengamma.engine.target.ComputationTargetType; import com.opengamma.engine.value.ValuePropertyNames; import com.opengamma.engine.value.ValueRequirement; import com.opengamma.engine.value.ValueRequirementNames; import com.opengamma.financial.analytics.OpenGammaFunctionExclusions; import com.opengamma.financial.analytics.model.InterpolatedDataProperties; import com.opengamma.financial.analytics.model.forex.ForexVisitors; import com.opengamma.financial.analytics.model.forex.option.black.FXOptionBlackFunction; import com.opengamma.financial.analytics.model.forex.option.callspreadblack.FXDigitalCallSpreadBlackFunction; import com.opengamma.financial.property.DefaultPropertyFunction; import com.opengamma.financial.security.FinancialSecurity; import com.opengamma.financial.security.option.FXDigitalOptionSecurity; import com.opengamma.util.ArgumentChecker; import com.opengamma.util.money.Currency; /** * @deprecated Use the version that does not refer to put and call currencies */ @Deprecated public class FXDigitalCallSpreadBlackDeltaPnLDefaultsDeprecated extends DefaultPropertyFunction { private final String _putCurveName; private final String _callCurveName; private final String _putCurveConfig; private final String _callCurveConfig; private final String _surfaceName; private final String _interpolatorName; private final String _leftExtrapolatorName; private final String _rightExtrapolatorName; private final String _callSpread; private final String _samplingPeriod; private final String _scheduleCalculator; private final String _samplingFunction; private final String _putCurrency; private final String _callCurrency; public FXDigitalCallSpreadBlackDeltaPnLDefaultsDeprecated(final String putCurveName, final String callCurveName, final String putCurveConfig, final String callCurveConfig, final String surfaceName, final String interpolatorName, final String leftExtrapolatorName, final String rightExtrapolatorName, final String callSpread, final String samplingPeriod, final String scheduleCalculator, final String samplingFunction, final String putCurrency, final String callCurrency) { super(ComputationTargetType.POSITION, true); ArgumentChecker.notNull(putCurveName, "put curve name"); ArgumentChecker.notNull(callCurveName, "call curve name"); ArgumentChecker.notNull(putCurveConfig, "put curve config"); ArgumentChecker.notNull(callCurveConfig, "call curve config"); ArgumentChecker.notNull(surfaceName, "surface name"); ArgumentChecker.notNull(interpolatorName, "interpolator name"); ArgumentChecker.notNull(leftExtrapolatorName, "left extrapolator name"); ArgumentChecker.notNull(rightExtrapolatorName, "right extrapolator name"); ArgumentChecker.notNull(callSpread, "call spread"); ArgumentChecker.notNull(samplingPeriod, "sampling period"); ArgumentChecker.notNull(scheduleCalculator, "schedule calculator"); ArgumentChecker.notNull(samplingFunction, "sampling function"); ArgumentChecker.notNull(putCurrency, "put currency"); ArgumentChecker.notNull(callCurrency, "call currency"); _putCurveName = putCurveName; _callCurveName = callCurveName; _putCurveConfig = putCurveConfig; _callCurveConfig = callCurveConfig; _surfaceName = surfaceName; _interpolatorName = interpolatorName; _leftExtrapolatorName = leftExtrapolatorName; _rightExtrapolatorName = rightExtrapolatorName; _callSpread = callSpread; _samplingPeriod = samplingPeriod; _scheduleCalculator = scheduleCalculator; _samplingFunction = samplingFunction; _putCurrency = putCurrency; _callCurrency = callCurrency; } @Override public boolean canApplyTo(final FunctionCompilationContext context, final ComputationTarget target) { if (!(target.getPosition().getSecurity() instanceof FinancialSecurity)) { return false; } final FinancialSecurity security = (FinancialSecurity) target.getPosition().getSecurity(); if (!(security instanceof FXDigitalOptionSecurity)) { return false; } final Currency putCurrency = security.accept(ForexVisitors.getPutCurrencyVisitor()); final Currency callCurrency = security.accept(ForexVisitors.getCallCurrencyVisitor()); return callCurrency.getCode().equals(_callCurrency) && putCurrency.getCode().equals(_putCurrency); } @Override protected void getDefaults(final PropertyDefaults defaults) { defaults.addValuePropertyName(ValueRequirementNames.PNL_SERIES, FXOptionBlackFunction.PUT_CURVE); defaults.addValuePropertyName(ValueRequirementNames.PNL_SERIES, FXOptionBlackFunction.CALL_CURVE); defaults.addValuePropertyName(ValueRequirementNames.PNL_SERIES, FXOptionBlackFunction.PUT_CURVE_CALC_CONFIG); defaults.addValuePropertyName(ValueRequirementNames.PNL_SERIES, FXOptionBlackFunction.CALL_CURVE_CALC_CONFIG); defaults.addValuePropertyName(ValueRequirementNames.PNL_SERIES, ValuePropertyNames.SURFACE); defaults.addValuePropertyName(ValueRequirementNames.PNL_SERIES, InterpolatedDataProperties.X_INTERPOLATOR_NAME); defaults.addValuePropertyName(ValueRequirementNames.PNL_SERIES, InterpolatedDataProperties.LEFT_X_EXTRAPOLATOR_NAME); defaults.addValuePropertyName(ValueRequirementNames.PNL_SERIES, InterpolatedDataProperties.RIGHT_X_EXTRAPOLATOR_NAME); defaults.addValuePropertyName(ValueRequirementNames.PNL_SERIES, FXDigitalCallSpreadBlackFunction.PROPERTY_CALL_SPREAD_VALUE); defaults.addValuePropertyName(ValueRequirementNames.PNL_SERIES, ValuePropertyNames.SAMPLING_PERIOD); defaults.addValuePropertyName(ValueRequirementNames.PNL_SERIES, ValuePropertyNames.SCHEDULE_CALCULATOR); defaults.addValuePropertyName(ValueRequirementNames.PNL_SERIES, ValuePropertyNames.SAMPLING_FUNCTION); } @Override protected Set<String> getDefaultValue(final FunctionCompilationContext context, final ComputationTarget target, final ValueRequirement desiredValue, final String propertyName) { if (FXOptionBlackFunction.CALL_CURVE.equals(propertyName)) { return Collections.singleton(_callCurveName); } if (FXOptionBlackFunction.PUT_CURVE.equals(propertyName)) { return Collections.singleton(_putCurveName); } if (FXOptionBlackFunction.CALL_CURVE_CALC_CONFIG.equals(propertyName)) { return Collections.singleton(_callCurveConfig); } if (FXOptionBlackFunction.PUT_CURVE_CALC_CONFIG.equals(propertyName)) { return Collections.singleton(_putCurveConfig); } if (ValuePropertyNames.SURFACE.equals(propertyName)) { return Collections.singleton(_surfaceName); } if (InterpolatedDataProperties.X_INTERPOLATOR_NAME.equals(propertyName)) { return Collections.singleton(_interpolatorName); } if (InterpolatedDataProperties.LEFT_X_EXTRAPOLATOR_NAME.equals(propertyName)) { return Collections.singleton(_leftExtrapolatorName); } if (InterpolatedDataProperties.RIGHT_X_EXTRAPOLATOR_NAME.equals(propertyName)) { return Collections.singleton(_rightExtrapolatorName); } if (FXDigitalCallSpreadBlackFunction.PROPERTY_CALL_SPREAD_VALUE.equals(propertyName)) { return Collections.singleton(_callSpread); } if (ValuePropertyNames.SAMPLING_PERIOD.equals(propertyName)) { return Collections.singleton(_samplingPeriod); } if (ValuePropertyNames.SCHEDULE_CALCULATOR.equals(propertyName)) { return Collections.singleton(_scheduleCalculator); } if (ValuePropertyNames.SAMPLING_FUNCTION.equals(propertyName)) { return Collections.singleton(_samplingFunction); } return null; } @Override public String getMutualExclusionGroup() { return OpenGammaFunctionExclusions.PNL_SERIES; } }