@SuppressWarnings("synthetic-access")
 @Override
 public InstrumentDerivative convert(
     final CapFloorCMSSpreadSecurity security,
     final AnnuityCapFloorCMSSpreadDefinition definition,
     final ZonedDateTime now,
     final String[] curveNames,
     final HistoricalTimeSeriesBundle timeSeries) {
   final ExternalId longId = security.getLongId();
   final ExternalId shortId = security.getShortId();
   final DoubleTimeSeries<ZonedDateTime> indexLongTS =
       getIndexTimeSeries(getIndexIdBundle(longId), now.getZone(), timeSeries);
   final DoubleTimeSeries<ZonedDateTime> indexShortTS =
       getIndexTimeSeries(getIndexIdBundle(shortId), now.getZone(), timeSeries);
   final DoubleTimeSeries<ZonedDateTime> indexSpreadTS =
       indexLongTS.subtract(indexShortTS);
   return definition.toDerivative(now, indexSpreadTS, curveNames);
 }
 @SuppressWarnings("synthetic-access")
 @Override
 public Set<ValueRequirement> getTimeSeriesRequirements(
     final CapFloorCMSSpreadSecurity security, final String[] curveNames) {
   final ExternalId longId = security.getLongId();
   final ExternalId shortId = security.getShortId();
   final ZonedDateTime capStartDate = security.getStartDate();
   final LocalDate startDate =
       capStartDate
           .toLocalDate()
           .minusDays(7); // To catch first fixing. SwapSecurity does not have this date.
   final ValueRequirement indexLongTS =
       getIndexTimeSeriesRequirement(getIndexIdBundle(longId), startDate);
   if (indexLongTS == null) {
     return null;
   }
   final ValueRequirement indexShortTS =
       getIndexTimeSeriesRequirement(getIndexIdBundle(shortId), startDate);
   if (indexShortTS == null) {
     return null;
   }
   return ImmutableSet.of(indexLongTS, indexShortTS);
 }
Beispiel #3
0
  protected void addSecuritySpecificMetaData(ManageableSecurity security, FlexiBean out) {
    if (security.getSecurityType().equals(SwapSecurity.SECURITY_TYPE)) {
      SwapSecurity swapSecurity = (SwapSecurity) security;
      out.put("payLegType", swapSecurity.getPayLeg().accept(new SwapLegClassifierVisitor()));
      out.put(
          "receiveLegType", swapSecurity.getReceiveLeg().accept(new SwapLegClassifierVisitor()));
    }
    if (security.getSecurityType().equals(FutureSecurity.SECURITY_TYPE)) {
      FutureSecurity futureSecurity = (FutureSecurity) security;
      out.put("futureSecurityType", futureSecurity.accept(new FutureSecurityTypeVisitor()));
      out.put("basket", getBondFutureBasket(security));
      Security underlyingSecurity = getUnderlyingFutureSecurity(futureSecurity);
      if (underlyingSecurity != null) {
        out.put("underlyingSecurity", underlyingSecurity);
      }
    }
    if (security.getSecurityType().equals(EquityOptionSecurity.SECURITY_TYPE)) {
      EquityOptionSecurity equityOption = (EquityOptionSecurity) security;
      addUnderlyingSecurity(out, equityOption.getUnderlyingId());
    }
    if (security.getSecurityType().equals(IRFutureOptionSecurity.SECURITY_TYPE)) {
      IRFutureOptionSecurity irFutureOption = (IRFutureOptionSecurity) security;
      addUnderlyingSecurity(out, irFutureOption.getUnderlyingId());
    }
    if (security.getSecurityType().equals(SwaptionSecurity.SECURITY_TYPE)) {
      SwaptionSecurity swaptionSecurity = (SwaptionSecurity) security;
      addUnderlyingSecurity(out, swaptionSecurity.getUnderlyingId());
    }
    if (security.getSecurityType().equals(EquityBarrierOptionSecurity.SECURITY_TYPE)) {
      EquityBarrierOptionSecurity equityBarrierOptionSecurity =
          (EquityBarrierOptionSecurity) security;
      addUnderlyingSecurity(out, equityBarrierOptionSecurity.getUnderlyingId());
    }
    if (security.getSecurityType().equals(CapFloorSecurity.SECURITY_TYPE)) {
      CapFloorSecurity capFloorSecurity = (CapFloorSecurity) security;
      addUnderlyingSecurity(out, capFloorSecurity.getUnderlyingId());
    }
    if (security.getSecurityType().equals(CapFloorCMSSpreadSecurity.SECURITY_TYPE)) {
      CapFloorCMSSpreadSecurity capFloorCMSSpreadSecurity = (CapFloorCMSSpreadSecurity) security;
      Security shortUnderlying = getSecurity(capFloorCMSSpreadSecurity.getShortId());
      Security longUnderlying = getSecurity(capFloorCMSSpreadSecurity.getLongId());
      if (shortUnderlying != null) {
        out.put("shortSecurity", shortUnderlying);
      }
      if (longUnderlying != null) {
        out.put("longSecurity", longUnderlying);
      }
    }
    if (security.getSecurityType().equals(EquityIndexOptionSecurity.SECURITY_TYPE)) {
      EquityIndexOptionSecurity equityIndxOption = (EquityIndexOptionSecurity) security;
      addUnderlyingSecurity(out, equityIndxOption.getUnderlyingId());
    }
    if (security.getSecurityType().equals(FRASecurity.SECURITY_TYPE)) {
      FRASecurity fraSecurity = (FRASecurity) security;
      addUnderlyingSecurity(out, fraSecurity.getUnderlyingId());
    }
    if (security.getSecurityType().equals(SecurityEntryData.EXTERNAL_SENSITIVITIES_SECURITY_TYPE)) {
      RawSecurity rawSecurity = (RawSecurity) security;
      FudgeMsgEnvelope msg =
          OpenGammaFudgeContext.getInstance().deserialize(rawSecurity.getRawData());
      SecurityEntryData securityEntryData =
          OpenGammaFudgeContext.getInstance()
              .fromFudgeMsg(SecurityEntryData.class, msg.getMessage());

      out.put("securityEntryData", securityEntryData);
      out.put("securityAttributes", security.getAttributes());
      RawSecurity underlyingRawSecurity =
          (RawSecurity) getSecurity(securityEntryData.getFactorSetId());
      if (underlyingRawSecurity != null) {
        FudgeMsgEnvelope factorIdMsg =
            OpenGammaFudgeContext.getInstance().deserialize(underlyingRawSecurity.getRawData());
        @SuppressWarnings("unchecked")
        List<FactorExposureData> factorExposureDataList =
            OpenGammaFudgeContext.getInstance().fromFudgeMsg(List.class, factorIdMsg.getMessage());
        s_logger.error(factorExposureDataList.toString());
        List<FactorExposure> factorExposuresList = convertToFactorExposure(factorExposureDataList);
        out.put("factorExposuresList", factorExposuresList);
      } else {
        s_logger.error("Couldn't find security");
      }
    }
    if (security
        .getSecurityType()
        .equals(FactorExposureData.EXTERNAL_SENSITIVITIES_RISK_FACTORS_SECURITY_TYPE)) {
      RawSecurity rawSecurity = (RawSecurity) security;
      FudgeMsgEnvelope msg =
          OpenGammaFudgeContext.getInstance().deserialize(rawSecurity.getRawData());
      @SuppressWarnings("unchecked")
      List<FactorExposureData> factorExposureDataList =
          OpenGammaFudgeContext.getInstance().fromFudgeMsg(List.class, msg.getMessage());
      List<FactorExposure> factorExposuresList = convertToFactorExposure(factorExposureDataList);
      out.put("factorExposuresList", factorExposuresList);
    }
  }