// FunctionInvoker
@Override
public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
final Position position = target.getPosition();
final ZonedDateTime now = ZonedDateTime.now(executionContext.getValuationClock());
final ValueRequirement desiredValue = desiredValues.iterator().next();
final String samplingPeriod = desiredValue.getConstraint(ValuePropertyNames.SAMPLING_PERIOD);
final String scheduleCalculator = desiredValue.getConstraint(ValuePropertyNames.SCHEDULE_CALCULATOR);
final String samplingFunction = desiredValue.getConstraint(ValuePropertyNames.SAMPLING_FUNCTION);
final FinancialSecurity security = (FinancialSecurity) position.getSecurity();
final MultipleCurrencyAmount mca = (MultipleCurrencyAmount) inputs.getValue(ValueRequirementNames.FX_CURRENCY_EXPOSURE);
final LocalDateDoubleTimeSeries timeSeries = (LocalDateDoubleTimeSeries) inputs.getValue(ValueRequirementNames.HISTORICAL_FX_TIME_SERIES);
final LocalDate startDate = now.toLocalDate().minus(Period.parse(samplingPeriod));
final Schedule schedule = ScheduleCalculatorFactory.getScheduleCalculator(scheduleCalculator);
final TimeSeriesSamplingFunction sampling = TimeSeriesSamplingFunctionFactory.getFunction(samplingFunction);
final Currency putCurrency = security.accept(ForexVisitors.getPutCurrencyVisitor());
final Currency callCurrency = security.accept(ForexVisitors.getCallCurrencyVisitor());
final CurrencyPairs currencyPairs = OpenGammaExecutionContext.getCurrencyPairsSource(executionContext).getCurrencyPairs(CurrencyPairs.DEFAULT_CURRENCY_PAIRS);
final CurrencyPair currencyPair = currencyPairs.getCurrencyPair(putCurrency, callCurrency);
final Currency currencyNonBase = currencyPair.getCounter(); // The non-base currency
final double delta = mca.getAmount(currencyNonBase);
DoubleTimeSeries<?> result = getPnLSeries(startDate, now.toLocalDate(), schedule, sampling, timeSeries);
result = result.multiply(position.getQuantity().doubleValue() * delta);
final ValueSpecification spec = new ValueSpecification(ValueRequirementNames.PNL_SERIES, target.toSpecification(), desiredValue.getConstraints());
return Collections.singleton(new ComputedValue(spec, result));
}