@SuppressWarnings("synthetic-access")
 @Override
 public InstrumentDerivative convert(
     final FRASecurity security,
     final ForwardRateAgreementDefinition definition,
     final ZonedDateTime now,
     final String[] curveNames,
     final HistoricalTimeSeriesBundle timeSeries) {
   final ExternalId indexId = security.getUnderlyingId();
   final ConventionBundle indexConvention = _conventionSource.getConventionBundle(indexId);
   if (indexConvention == null) {
     throw new OpenGammaRuntimeException(
         "No conventions found for floating reference rate " + indexId);
   }
   final ExternalIdBundle indexIdBundle = indexConvention.getIdentifiers();
   final HistoricalTimeSeries ts =
       timeSeries.get(MarketDataRequirementNames.MARKET_VALUE, indexIdBundle);
   if (ts == null) {
     throw new OpenGammaRuntimeException(
         "Could not get price time series for " + indexIdBundle);
   }
   FastBackedDoubleTimeSeries<LocalDate> localDateTS = ts.getTimeSeries();
   // TODO this normalization should not be done here
   localDateTS = localDateTS.divide(100);
   final FastLongDoubleTimeSeries convertedTS =
       localDateTS.toFastLongDoubleTimeSeries(DateTimeNumericEncoding.TIME_EPOCH_MILLIS);
   final LocalTime fixingTime = LocalTime.of(0, 0);
   final DoubleTimeSeries<ZonedDateTime> indexTS =
       new ArrayZonedDateTimeDoubleTimeSeries(
           new ZonedDateTimeEpochMillisConverter(now.getZone(), fixingTime), convertedTS);
   // TODO: remove the zone
   return definition.toDerivative(now, indexTS, curveNames);
 }
 private DoubleTimeSeries<ZonedDateTime> getIndexTimeSeries(
     final SwapLeg leg,
     final ZonedDateTime swapEffectiveDate,
     final ZonedDateTime now,
     final boolean includeEndDate,
     final HistoricalTimeSeriesBundle timeSeries) {
   if (leg instanceof FloatingInterestRateLeg) {
     final FloatingInterestRateLeg floatingLeg = (FloatingInterestRateLeg) leg;
     final ExternalIdBundle id = getIndexIdForSwap(floatingLeg);
     // Implementation note: To catch first fixing. SwapSecurity does not have this date.
     if (now.isBefore(swapEffectiveDate)) { // TODO: review if this is the correct condition
       return ArrayZonedDateTimeDoubleTimeSeries.EMPTY_SERIES;
     }
     final HistoricalTimeSeries ts = timeSeries.get(MarketDataRequirementNames.MARKET_VALUE, id);
     if (ts == null) {
       throw new OpenGammaRuntimeException(
           "Could not get time series of underlying index "
               + id.getExternalIds().toString()
               + " bundle used was "
               + id);
     }
     if (ts.getTimeSeries().isEmpty()) {
       return ArrayZonedDateTimeDoubleTimeSeries.EMPTY_SERIES;
     }
     final FastBackedDoubleTimeSeries<LocalDate> localDateTS = ts.getTimeSeries();
     final FastLongDoubleTimeSeries convertedTS =
         localDateTS.toFastLongDoubleTimeSeries(DateTimeNumericEncoding.TIME_EPOCH_MILLIS);
     final LocalTime fixingTime =
         LocalTime.of(
             0,
             0); // FIXME CASE Converting a daily historical time series to an arbitrary time. Bad
                 // idea
     return new ArrayZonedDateTimeDoubleTimeSeries(
         new ZonedDateTimeEpochMillisConverter(now.getZone(), fixingTime), convertedTS);
   }
   return null;
 }
 /**
  * Returns the time series to be used in the toDerivative method.
  *
  * @param id The ExternalId bundle.
  * @param startDate The time series start date (included in the time series).
  * @param timeZone The time zone to use for the returned series
  * @param dataSource The time series data source.
  * @return The time series.
  */
 private DoubleTimeSeries<ZonedDateTime> getIndexTimeSeries(
     final ExternalIdBundle id,
     final TimeZone timeZone,
     final HistoricalTimeSeriesBundle timeSeries) {
   final HistoricalTimeSeries ts = timeSeries.get(MarketDataRequirementNames.MARKET_VALUE, id);
   // Implementation note: the normalization take place in the getHistoricalTimeSeries
   if (ts == null) {
     throw new OpenGammaRuntimeException(
         "Could not get time series of underlying index " + id.getExternalIds().toString());
   }
   if (ts.getTimeSeries().isEmpty()) {
     return ArrayZonedDateTimeDoubleTimeSeries.EMPTY_SERIES;
   }
   final FastBackedDoubleTimeSeries<LocalDate> localDateTS = ts.getTimeSeries();
   final FastLongDoubleTimeSeries convertedTS =
       localDateTS.toFastLongDoubleTimeSeries(DateTimeNumericEncoding.TIME_EPOCH_MILLIS);
   final LocalTime fixingTime =
       LocalTime.of(
           0,
           0); // FIXME CASE Converting a daily historical time series to an arbitrary time. Bad
               // idea
   return new ArrayZonedDateTimeDoubleTimeSeries(
       new ZonedDateTimeEpochMillisConverter(timeZone, fixingTime), convertedTS);
 }
 @Override
 public InstrumentDerivative convert(
     final CapFloorSecurity security,
     final AnnuityCapFloorIborDefinition definition,
     final ZonedDateTime now,
     final String[] curveNames,
     final HistoricalTimeSeriesBundle timeSeries) {
   final ExternalId id = security.getUnderlyingId();
   final HistoricalTimeSeries ts =
       timeSeries.get(MarketDataRequirementNames.MARKET_VALUE, security.getUnderlyingId());
   if (ts == null) {
     throw new OpenGammaRuntimeException("Could not get price time series for " + id);
   }
   FastBackedDoubleTimeSeries<LocalDate> localDateTS = ts.getTimeSeries();
   // TODO this normalization should not be done here
   localDateTS = localDateTS.divide(100);
   final FastLongDoubleTimeSeries convertedTS =
       localDateTS.toFastLongDoubleTimeSeries(DateTimeNumericEncoding.TIME_EPOCH_MILLIS);
   final LocalTime fixingTime = LocalTime.of(11, 0);
   final DoubleTimeSeries<ZonedDateTime> indexTS =
       new ArrayZonedDateTimeDoubleTimeSeries(
           new ZonedDateTimeEpochMillisConverter(now.getZone(), fixingTime), convertedTS);
   return definition.toDerivative(now, indexTS, curveNames);
 }