@Override
 public Set<ValueRequirement> getTimeSeriesRequirements(
     final FRASecurity security, final String[] curveNames) {
   final ExternalId indexId = security.getUnderlyingId();
   final ConventionBundle indexConvention =
       getConventionSource().getConventionBundle(indexId);
   if (indexConvention == null) {
     throw new OpenGammaRuntimeException(
         "No conventions found for floating reference rate " + indexId);
   }
   final ExternalIdBundle indexIdBundle = indexConvention.getIdentifiers();
   final HistoricalTimeSeriesResolutionResult timeSeries =
       getTimeSeriesResolver()
           .resolve(
               indexIdBundle,
               null,
               null,
               null,
               MarketDataRequirementNames.MARKET_VALUE,
               null);
   if (timeSeries == null) {
     return null;
   }
   return Collections.singleton(
       HistoricalTimeSeriesFunctionUtils.createHTSRequirement(
           timeSeries,
           MarketDataRequirementNames.MARKET_VALUE,
           DateConstraint.VALUATION_TIME.minus(Period.ofDays(7)).previousWeekDay(),
           true,
           DateConstraint.VALUATION_TIME,
           false));
 }
 @Override
 public Set<ValueRequirement> getTimeSeriesRequirements(
     final IRFutureOptionSecurity security, final String[] curveNames) {
   final HistoricalTimeSeriesResolutionResult timeSeries =
       getTimeSeriesResolver()
           .resolve(
               security.getExternalIdBundle(),
               null,
               null,
               null,
               MarketDataRequirementNames.MARKET_VALUE,
               null);
   if (timeSeries == null) {
     return null;
   }
   return Collections.singleton(
       HistoricalTimeSeriesFunctionUtils.createHTSRequirement(
           timeSeries,
           MarketDataRequirementNames.MARKET_VALUE,
           DateConstraint.VALUATION_TIME.minus(Period.ofMonths(1)).previousWeekDay(),
           true,
           DateConstraint.VALUATION_TIME,
           false));
 }
 @Override
 public Set<ValueRequirement> getRequirements(
     final FunctionCompilationContext context,
     final ComputationTarget target,
     final ValueRequirement desiredValue) {
   final Object positionOrNode = getTarget(target);
   final Set<ValueRequirement> result = new HashSet<ValueRequirement>();
   final ValueProperties constraints = desiredValue.getConstraints();
   final Set<String> samplingPeriodNames =
       constraints.getValues(ValuePropertyNames.SAMPLING_PERIOD);
   if (samplingPeriodNames == null || samplingPeriodNames.size() != 1) {
     return null;
   }
   final Set<String> scheduleCalculatorNames =
       constraints.getValues(ValuePropertyNames.SCHEDULE_CALCULATOR);
   if (scheduleCalculatorNames == null || scheduleCalculatorNames.size() != 1) {
     return null;
   }
   final Set<String> samplingFunctionNames =
       constraints.getValues(ValuePropertyNames.SAMPLING_FUNCTION);
   if (samplingFunctionNames == null || samplingFunctionNames.size() != 1) {
     return null;
   }
   final Set<String> returnCalculatorNames =
       constraints.getValues(ValuePropertyNames.RETURN_CALCULATOR);
   if (returnCalculatorNames == null || returnCalculatorNames.size() != 1) {
     return null;
   }
   final Set<String> stdDevCalculatorNames =
       constraints.getValues(ValuePropertyNames.STD_DEV_CALCULATOR);
   if (stdDevCalculatorNames == null || stdDevCalculatorNames.size() != 1) {
     return null;
   }
   final Set<String> covarianceCalculatorNames =
       constraints.getValues(ValuePropertyNames.COVARIANCE_CALCULATOR);
   if (covarianceCalculatorNames == null || covarianceCalculatorNames.size() != 1) {
     return null;
   }
   final Set<String> varianceCalculatorNames =
       constraints.getValues(ValuePropertyNames.VARIANCE_CALCULATOR);
   if (varianceCalculatorNames == null || varianceCalculatorNames.size() != 1) {
     return null;
   }
   final String samplingPeriodName = samplingPeriodNames.iterator().next();
   final String scheduleCalculatorName = scheduleCalculatorNames.iterator().next();
   final String samplingFunctionName = samplingFunctionNames.iterator().next();
   final String returnCalculatorName = returnCalculatorNames.iterator().next();
   final ValueProperties pnlSeriesProperties =
       ValueProperties.builder()
           .withAny(ValuePropertyNames.CURRENCY)
           .with(ValuePropertyNames.SAMPLING_PERIOD, samplingPeriodName)
           .with(ValuePropertyNames.SCHEDULE_CALCULATOR, scheduleCalculatorName)
           .with(ValuePropertyNames.SAMPLING_FUNCTION, samplingFunctionName)
           .with(ValuePropertyNames.RETURN_CALCULATOR, returnCalculatorName)
           .get();
   final ValueProperties betaProperties =
       ValueProperties.builder()
           .with(ValuePropertyNames.SAMPLING_PERIOD, samplingPeriodName)
           .with(ValuePropertyNames.SCHEDULE_CALCULATOR, scheduleCalculatorName)
           .with(ValuePropertyNames.SAMPLING_FUNCTION, samplingFunctionName)
           .with(ValuePropertyNames.RETURN_CALCULATOR, returnCalculatorName)
           .with(
               ValuePropertyNames.COVARIANCE_CALCULATOR,
               covarianceCalculatorNames.iterator().next())
           .with(ValuePropertyNames.VARIANCE_CALCULATOR, varianceCalculatorNames.iterator().next())
           .get();
   result.add(
       new ValueRequirement(
           ValueRequirementNames.PNL_SERIES, positionOrNode, pnlSeriesProperties));
   result.add(new ValueRequirement(ValueRequirementNames.FAIR_VALUE, positionOrNode));
   result.add(
       new ValueRequirement(ValueRequirementNames.CAPM_BETA, positionOrNode, betaProperties));
   final HistoricalTimeSeriesResolver resolver =
       OpenGammaCompilationContext.getHistoricalTimeSeriesResolver(context);
   final ConventionBundleSource conventionSource =
       OpenGammaCompilationContext.getConventionBundleSource(context);
   final ConventionBundle bundle =
       conventionSource.getConventionBundle(
           ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "USD_CAPM"));
   final HistoricalTimeSeriesResolutionResult timeSeries =
       resolver.resolve(
           bundle.getCAPMMarket(),
           null,
           null,
           null,
           MarketDataRequirementNames.MARKET_VALUE,
           _resolutionKey);
   if (timeSeries == null) {
     return null;
   }
   result.add(
       HistoricalTimeSeriesFunctionUtils.createHTSRequirement(
           timeSeries,
           MarketDataRequirementNames.MARKET_VALUE,
           DateConstraint.VALUATION_TIME.minus(samplingPeriodName),
           true,
           DateConstraint.VALUATION_TIME,
           true));
   return result;
 }