@Override
 public Set<ValueRequirement> getRequirements(
     final FunctionCompilationContext context,
     final ComputationTarget target,
     final ValueRequirement desiredValue) {
   final Set<String> curves = desiredValue.getConstraints().getValues(ValuePropertyNames.CURVE);
   final Set<String> curveCalcConfigs =
       desiredValue.getConstraints().getValues(ValuePropertyNames.CURVE_CALCULATION_CONFIG);
   if ((curves == null) || (curves.size() != 1)) {
     s_logger.warn("no curve specified");
     // Can't support an unbound request; an injection function must be used (or declare all as
     // optional and use [PLAT-1771])
     return null;
   }
   if ((curveCalcConfigs == null) || (curveCalcConfigs.size() != 1)) {
     s_logger.warn("no curve config specified");
     return null;
   }
   final String curve = curves.iterator().next();
   final String curveCalcConfig = curveCalcConfigs.iterator().next();
   final Set<ValueRequirement> requirements = Sets.newHashSet();
   requirements.add(getCurveRequirement(target, curve, curveCalcConfig));
   requirements.add(getCurveSpecRequirement(target, curve));
   requirements.addAll(
       getSensitivityRequirements(
           context.getSecuritySource(), (RawSecurity) target.getSecurity()));
   return requirements;
 }
  @Override
  public Set<ValueRequirement> getRequirements(
      final FunctionCompilationContext context,
      final ComputationTarget target,
      final ValueRequirement desiredValue) {
    final LegacyVanillaCDSSecurity cds = (LegacyVanillaCDSSecurity) target.getSecurity();
    final Currency ccy = cds.getNotional().getCurrency();
    final CreditCurveIdentifier isdaIdentifier = getISDACurveIdentifier(cds);
    final CreditCurveIdentifier spreadIdentifier = getSpreadCurveIdentifier(cds);

    final String isdaOffset = desiredValue.getConstraint(ISDAFunctionConstants.ISDA_CURVE_OFFSET);
    if (isdaOffset == null) {
      return null;
    }

    final String isdaCurveDate = desiredValue.getConstraint(ISDAFunctionConstants.ISDA_CURVE_DATE);
    if (isdaCurveDate == null) {
      return null;
    }

    final String isdaCurveMethod =
        desiredValue.getConstraint(ISDAFunctionConstants.ISDA_IMPLEMENTATION);
    if (isdaCurveMethod == null) {
      return null;
    }

    // isda curve
    final ValueProperties isdaProperties =
        ValueProperties.builder()
            .with(ValuePropertyNames.CURVE, isdaIdentifier.toString())
            .with(
                ValuePropertyNames.CURVE_CALCULATION_METHOD, ISDAFunctionConstants.ISDA_METHOD_NAME)
            .with(ISDAFunctionConstants.ISDA_CURVE_OFFSET, isdaOffset)
            .with(ISDAFunctionConstants.ISDA_CURVE_DATE, isdaCurveDate)
            .with(ISDAFunctionConstants.ISDA_IMPLEMENTATION, isdaCurveMethod)
            .get();
    final ValueRequirement isdaRequirment =
        new ValueRequirement(
            ValueRequirementNames.YIELD_CURVE,
            ComputationTargetType.CURRENCY,
            ccy.getUniqueId(),
            isdaProperties);

    final String quoteConvention =
        desiredValue.getConstraint(ISDAFunctionConstants.CDS_QUOTE_CONVENTION);
    if (quoteConvention == null) {
      return null;
    }

    final String bucketTenors =
        desiredValue.getConstraint(ISDAFunctionConstants.ISDA_BUCKET_TENORS);
    if (bucketTenors == null) {
      return null;
    }

    // market  spreads
    final ValueProperties spreadProperties =
        ValueProperties.builder()
            .with(ISDAFunctionConstants.CDS_QUOTE_CONVENTION, quoteConvention)
            .with(
                ValuePropertyNames.CURVE_CALCULATION_METHOD, ISDAFunctionConstants.ISDA_METHOD_NAME)
            .with(ISDAFunctionConstants.ISDA_CURVE_OFFSET, isdaOffset)
            .with(ISDAFunctionConstants.ISDA_CURVE_DATE, isdaCurveDate)
            .with(ISDAFunctionConstants.ISDA_IMPLEMENTATION, isdaCurveMethod)
            .with(ISDAFunctionConstants.ISDA_BUCKET_TENORS, bucketTenors)
            .get();
    final ValueRequirement spreadRequirment =
        new ValueRequirement(
            ValueRequirementNames.BUCKETED_SPREADS, target.toSpecification(), spreadProperties);
    final ValueRequirement pillarRequirment =
        new ValueRequirement(
            ValueRequirementNames.PILLAR_SPREADS, target.toSpecification(), spreadProperties);
    final ValueRequirement creditCurveRequirement =
        new ValueRequirement(
            ValueRequirementNames.HAZARD_RATE_CURVE, target.toSpecification(), spreadProperties);

    // get individual spread for this cds (ignore business day adjustment on either)
    final Period period =
        Period.between(
            cds.getStartDate().toLocalDate().withDayOfMonth(20),
            cds.getMaturityDate().toLocalDate().withDayOfMonth(20));
    final ValueRequirement cdsSpreadRequirement =
        new ValueRequirement(
            MarketDataRequirementNames.MARKET_VALUE,
            ComputationTargetType.PRIMITIVE,
            ExternalId.of("Tenor", period.toString()));

    final CdsRecoveryRateIdentifier recoveryRateIdentifier =
        cds.accept(new CreditSecurityToRecoveryRateVisitor(context.getSecuritySource()));
    final ValueRequirement recoveryRateRequirement =
        new ValueRequirement(
            "PX_LAST", ComputationTargetType.PRIMITIVE, recoveryRateIdentifier.getExternalId());

    return Sets.newHashSet(
        isdaRequirment,
        spreadRequirment,
        cdsSpreadRequirement,
        creditCurveRequirement,
        pillarRequirment,
        recoveryRateRequirement);
  }