コード例 #1
1
 @SuppressWarnings("synthetic-access")
 @Override
 public Set<ValueRequirement> getTimeSeriesRequirements(
     final SwapSecurity security, final String[] curveNames) {
   Validate.notNull(security, "security");
   final SwapLeg payLeg = security.getPayLeg();
   final SwapLeg receiveLeg = security.getReceiveLeg();
   final ZonedDateTime swapStartDate = security.getEffectiveDate();
   final ZonedDateTime swapStartLocalDate =
       ZonedDateTime.of(swapStartDate.toLocalDate(), LocalTime.of(0, 0), TimeZone.UTC);
   final ValueRequirement payLegTS =
       getIndexTimeSeriesRequirement(
           InterestRateInstrumentType.getInstrumentTypeFromSecurity(security),
           payLeg,
           swapStartLocalDate);
   final ValueRequirement receiveLegTS =
       getIndexTimeSeriesRequirement(
           InterestRateInstrumentType.getInstrumentTypeFromSecurity(security),
           receiveLeg,
           swapStartLocalDate);
   final Set<ValueRequirement> requirements = new HashSet<ValueRequirement>();
   if (payLegTS != null) {
     requirements.add(payLegTS);
   }
   if (receiveLegTS != null) {
     requirements.add(receiveLegTS);
   }
   return requirements;
 }
コード例 #2
0
 @Override
 public boolean canApplyTo(
     final FunctionCompilationContext context, final ComputationTarget target) {
   if (!(target.getSecurity() instanceof FinancialSecurity)) {
     return false;
   }
   final FinancialSecurity security = (FinancialSecurity) target.getSecurity();
   // TODO remove this when we've checked that removing IR futures from the fixed income instrument
   // types
   // doesn't break curves
   if (target.getSecurity() instanceof InterestRateFutureSecurity) {
     return false;
   }
   if (security instanceof SwapSecurity) {
     try {
       final InterestRateInstrumentType type =
           InterestRateInstrumentType.getInstrumentTypeFromSecurity(security);
       return type == InterestRateInstrumentType.SWAP_FIXED_IBOR
           || type == InterestRateInstrumentType.SWAP_FIXED_IBOR_WITH_SPREAD
           || type == InterestRateInstrumentType.SWAP_IBOR_IBOR
           || type == InterestRateInstrumentType.SWAP_FIXED_OIS;
     } catch (final OpenGammaRuntimeException ogre) {
       return false;
     }
   }
   return InterestRateInstrumentType.isFixedIncomeInstrumentType(security);
 }
 @Override
 public boolean canApplyTo(
     final FunctionCompilationContext context, final ComputationTarget target) {
   final Security security = target.getSecurity();
   if (security instanceof SwapSecurity) {
     if (!InterestRateInstrumentType.isFixedIncomeInstrumentType((SwapSecurity) security)) {
       return false;
     }
     final InterestRateInstrumentType type =
         SwapSecurityUtils.getSwapType((SwapSecurity) security);
     if ((type != InterestRateInstrumentType.SWAP_FIXED_CMS)
         && (type != InterestRateInstrumentType.SWAP_CMS_CMS)
         && (type != InterestRateInstrumentType.SWAP_IBOR_CMS)) {
       return false;
     }
   }
   return true;
 }
コード例 #4
0
 @Override
 @SuppressWarnings({"unchecked", "synthetic-access"})
 public InstrumentDerivative convert(
     final SwapSecurity security,
     final SwapDefinition definition,
     final ZonedDateTime now,
     final String[] curveNames,
     final HistoricalTimeSeriesBundle timeSeries) {
   Validate.notNull(security, "security");
   final SwapLeg payLeg = security.getPayLeg();
   final SwapLeg receiveLeg = security.getReceiveLeg();
   final ZonedDateTime fixingSeriesStartDate =
       security.getEffectiveDate().isBefore(now) ? security.getEffectiveDate() : now;
   final ZonedDateTime fixingSeriesStartLocalDate =
       ZonedDateTime.of(
           fixingSeriesStartDate.toLocalDate(), LocalTime.of(0, 0), TimeZone.UTC);
   final boolean includeCurrentDatesFixing = true;
   final DoubleTimeSeries<ZonedDateTime> payLegTS =
       getIndexTimeSeries(
           payLeg, fixingSeriesStartLocalDate, now, includeCurrentDatesFixing, timeSeries);
   final DoubleTimeSeries<ZonedDateTime> receiveLegTS =
       getIndexTimeSeries(
           receiveLeg,
           fixingSeriesStartLocalDate,
           now,
           includeCurrentDatesFixing,
           timeSeries);
   if (payLegTS != null) {
     if (receiveLegTS != null) {
       try {
         return definition.toDerivative(
             now, new DoubleTimeSeries[] {payLegTS, receiveLegTS}, curveNames);
       } catch (final OpenGammaRuntimeException e) {
         final ExternalId id =
             ((FloatingInterestRateLeg) payLeg).getFloatingReferenceRateId();
         throw new OpenGammaRuntimeException(
             "Could not get fixing value for series with identifier " + id, e);
       }
     }
     if (InterestRateInstrumentType.getInstrumentTypeFromSecurity(security)
         == InterestRateInstrumentType.SWAP_FIXED_CMS) {
       return definition.toDerivative(
           now, new DoubleTimeSeries[] {payLegTS, payLegTS}, curveNames);
     }
     try {
       return definition.toDerivative(now, new DoubleTimeSeries[] {payLegTS}, curveNames);
     } catch (final OpenGammaRuntimeException e) {
       final ExternalId id = ((FloatingInterestRateLeg) payLeg).getFloatingReferenceRateId();
       throw new OpenGammaRuntimeException(
           "Could not get fixing value for series with identifier " + id, e);
     }
   }
   if (receiveLegTS != null) {
     if (InterestRateInstrumentType.getInstrumentTypeFromSecurity(security)
         == InterestRateInstrumentType.SWAP_FIXED_CMS) {
       try {
         return definition.toDerivative(
             now, new DoubleTimeSeries[] {receiveLegTS, receiveLegTS}, curveNames);
       } catch (final OpenGammaRuntimeException e) {
         final ExternalId id =
             ((FloatingInterestRateLeg) payLeg).getFloatingReferenceRateId();
         throw new OpenGammaRuntimeException(
             "Could not get fixing value for series with identifier " + id, e);
       }
     }
     try {
       return definition.toDerivative(
           now, new DoubleTimeSeries[] {receiveLegTS}, curveNames);
     } catch (final OpenGammaRuntimeException e) {
       final ExternalId id =
           ((FloatingInterestRateLeg) receiveLeg).getFloatingReferenceRateId();
       throw new OpenGammaRuntimeException(
           "Could not get fixing value for series with identifier " + id, e);
     }
   }
   throw new OpenGammaRuntimeException(
       "Could not get fixing series for either the pay or receive leg");
 }