}
@Override
public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
final ValueRequirement desiredValue = desiredValues.iterator().next();
final ComputedValue fairValueCV = inputs.getComputedValue(ValueRequirementNames.FAIR_VALUE);
final Object fairValueObj = fairValueCV.getValue();
if (fairValueObj == null) {
throw new OpenGammaRuntimeException("Asset fair value was null");
}
final double fairValue = (Double) fairValueObj;
final Object priceSeriesObj = inputs.getValue(ValueRequirementNames.PRICE_SERIES);
if (priceSeriesObj == null) {
throw new OpenGammaRuntimeException("Asset price series was null");
}
final Set<String> returnCalculatorNames = desiredValue.getConstraints().getValues(ValuePropertyNames.RETURN_CALCULATOR);
final TimeSeriesReturnCalculator returnCalculator = getTimeSeriesReturnCalculator(returnCalculatorNames);
final LocalDateDoubleTimeSeries returnSeries = (LocalDateDoubleTimeSeries) returnCalculator.evaluate((LocalDateDoubleTimeSeries) priceSeriesObj);
final ValueSpecification resultSpec = new ValueSpecification(ValueRequirementNames.PNL_SERIES, target.toSpecification(), desiredValue.getConstraints());
//final Object result = returnSeries.multiply(fairValue);
final Object result = returnSeries.multiply(fairValue).multiply(target.getPosition().getQuantity().doubleValue());
return Collections.singleton(new ComputedValue(resultSpec, result));
}