static InstrumentDerivative getDerivative(
     final FinancialSecurity security,
     final ZonedDateTime now,
     final HistoricalTimeSeriesBundle timeSeries,
     final String[] curveNames,
     final InstrumentDefinition<?> definition,
     final FixedIncomeConverterDataProvider definitionConverter) {
   final InstrumentDerivative derivative;
   if (security instanceof SwapSecurity) {
     final SwapSecurity swapSecurity = (SwapSecurity) security;
     final InterestRateInstrumentType type = SwapSecurityUtils.getSwapType(swapSecurity);
     if (type == InterestRateInstrumentType.SWAP_FIXED_IBOR
         || type == InterestRateInstrumentType.SWAP_FIXED_IBOR_WITH_SPREAD
         || type == InterestRateInstrumentType.SWAP_FIXED_OIS) {
       final Frequency resetFrequency;
       if (swapSecurity.getPayLeg() instanceof FloatingInterestRateLeg) {
         resetFrequency = ((FloatingInterestRateLeg) swapSecurity.getPayLeg()).getFrequency();
       } else {
         resetFrequency = ((FloatingInterestRateLeg) swapSecurity.getReceiveLeg()).getFrequency();
       }
       derivative =
           definitionConverter.convert(
               security,
               definition,
               now,
               FixedIncomeInstrumentCurveExposureHelper.getCurveNamesForSecurity(
                   security, curveNames, resetFrequency),
               timeSeries);
     } else {
       derivative =
           definitionConverter.convert(
               security,
               definition,
               now,
               FixedIncomeInstrumentCurveExposureHelper.getCurveNamesForSecurity(
                   security, curveNames),
               timeSeries);
     }
   } else {
     derivative =
         definitionConverter.convert(
             security,
             definition,
             now,
             FixedIncomeInstrumentCurveExposureHelper.getCurveNamesForSecurity(
                 security, curveNames),
             timeSeries);
   }
   return derivative;
 }
 @Override
 public Set<ComputedValue> execute(
     final FunctionExecutionContext executionContext,
     final FunctionInputs inputs,
     final ComputationTarget target,
     final Set<ValueRequirement> desiredValues) {
   final FinancialSecurity security = (FinancialSecurity) target.getSecurity();
   final Currency currency = FinancialSecurityUtils.getCurrency(security);
   final Clock snapshotClock = executionContext.getValuationClock();
   final ZonedDateTime now = snapshotClock.zonedDateTime();
   final HistoricalTimeSeriesBundle timeSeries =
       HistoricalTimeSeriesFunctionUtils.getHistoricalTimeSeriesInputs(executionContext, inputs);
   final ValueRequirement desiredValue = desiredValues.iterator().next();
   final String curveCalculationConfigName =
       desiredValue.getConstraint(ValuePropertyNames.CURVE_CALCULATION_CONFIG);
   final ConfigSource configSource = OpenGammaExecutionContext.getConfigSource(executionContext);
   final ConfigDBCurveCalculationConfigSource curveCalculationConfigSource =
       new ConfigDBCurveCalculationConfigSource(configSource);
   final MultiCurveCalculationConfig curveCalculationConfig =
       curveCalculationConfigSource.getConfig(curveCalculationConfigName);
   if (curveCalculationConfig == null) {
     throw new OpenGammaRuntimeException(
         "Could not find curve calculation configuration named " + curveCalculationConfigName);
   }
   final String[] curveNames = curveCalculationConfig.getYieldCurveNames();
   final String[] yieldCurveNames =
       curveNames.length == 1 ? new String[] {curveNames[0], curveNames[0]} : curveNames;
   final String[] curveNamesForSecurity =
       FixedIncomeInstrumentCurveExposureHelper.getCurveNamesForSecurity(
           security, yieldCurveNames[0], yieldCurveNames[1]);
   final YieldCurveBundle bundle =
       YieldCurveFunctionUtils.getAllYieldCurves(
           inputs, curveCalculationConfig, curveCalculationConfigSource);
   final InstrumentDefinition<?> definition = security.accept(_visitor);
   if (definition == null) {
     throw new OpenGammaRuntimeException("Definition for security " + security + " was null");
   }
   final InstrumentDerivative derivative =
       getDerivative(
           security, now, timeSeries, curveNamesForSecurity, definition, _definitionConverter);
   return getComputedValues(
       derivative, bundle, security, target, curveCalculationConfigName, currency.getCode());
 }