コード例 #1
0
  @Override
  public String classifyPosition(final Position position) {
    final Security security = resolveSecurity(position);
    if (security instanceof CreditDefaultSwapOptionSecurity) {
      final CreditDefaultSwapOptionSecurity cdsOption = (CreditDefaultSwapOptionSecurity) security;
      final ExternalId underlyingId = cdsOption.getUnderlyingId();
      final Security underlying = _securitySource.getSingle(underlyingId.toBundle());
      final String redCode =
          ((CreditDefaultSwapSecurity) underlying).getReferenceEntity().getValue();
      final Organization organisation = _organizationSource.getOrganizationByRedCode(redCode);
      return organisation.getObligor().getObligorShortName();

    } else if (security instanceof CreditDefaultSwapIndexSecurity) {
      final CreditDefaultSwapIndexSecurity cdsIndex = (CreditDefaultSwapIndexSecurity) security;
      final CreditDefaultSwapIndexDefinitionSecurity definition =
          (CreditDefaultSwapIndexDefinitionSecurity)
              _securitySource.getSingle(ExternalIdBundle.of(cdsIndex.getReferenceEntity()));
      return definition.getName();
    } else if (security instanceof CreditDefaultSwapSecurity) {
      final AbstractCreditDefaultSwapSecurity cds = (AbstractCreditDefaultSwapSecurity) security;
      final String redCode = cds.getReferenceEntity().getValue();
      final Organization organisation = _organizationSource.getOrganizationByRedCode(redCode);
      if (organisation != null) {
        return organisation.getObligor().getObligorShortName();
      } else {
        return redCode;
      }
    }

    return NOT_APPLICABLE;
  }
コード例 #2
0
 @Override
 public List<ExternalId> visitIRFutureOptionSecurity(final IRFutureOptionSecurity security) {
   final FutureSecurity underlyingSecurity =
       (FutureSecurity)
           _securitySource.getSingle(ExternalIdBundle.of(security.getUnderlyingId()));
   return getContractType(underlyingSecurity);
 }
コード例 #3
0
 @Override
 public List<ExternalId> visitCreditDefaultSwapOptionSecurity(
     final CreditDefaultSwapOptionSecurity security) {
   final CreditDefaultSwapSecurity underlyingCDS =
       (CreditDefaultSwapSecurity)
           _securitySource.getSingle(
               ExternalIdBundle.of(security.getUnderlyingId())); // TODO version
   final ExternalId regionId = underlyingCDS.getRegionId();
   final String securityType = security.getSecurityType();
   return Arrays.asList(
       ExternalId.of(SECURITY_IDENTIFIER, securityType + SEPARATOR + regionId.getValue()));
 }
コード例 #4
0
 @Override
 public Security getSingle(ExternalIdBundle bundle, VersionCorrection versionCorrection) {
   ArgumentChecker.notNull(bundle, "bundle");
   ArgumentChecker.notNull(versionCorrection, "versionCorrection");
   for (SecuritySource delegateSource : _delegator.getDelegates().values()) {
     Security result = delegateSource.getSingle(bundle, versionCorrection);
     if (result != null) {
       return result;
     }
   }
   return _delegator.getDefaultDelegate().getSingle(bundle, versionCorrection);
 }
コード例 #5
0
 @Override
 public Security getSingle(ExternalIdBundle bundle) {
   ArgumentChecker.notNull(bundle, "bundle");
   // best implementation is to return first matching result
   for (SecuritySource delegateSource : _delegator.getDelegates().values()) {
     Security result = delegateSource.getSingle(bundle);
     if (result != null) {
       return result;
     }
   }
   return _delegator.getDefaultDelegate().getSingle(bundle);
 }
コード例 #6
0
 public static List<FactorExposureData> decodeFactorExposureData(
     SecuritySource secSource, RawSecurity rawSecurity) {
   FudgeMsgEnvelope msg =
       OpenGammaFudgeContext.getInstance().deserialize(rawSecurity.getRawData());
   SecurityEntryData securityEntryData =
       OpenGammaFudgeContext.getInstance().fromFudgeMsg(SecurityEntryData.class, msg.getMessage());
   RawSecurity underlyingRawSecurity =
       (RawSecurity) secSource.getSingle(securityEntryData.getFactorSetId().toBundle());
   if (underlyingRawSecurity != null) {
     FudgeMsgEnvelope factorIdMsg =
         OpenGammaFudgeContext.getInstance().deserialize(underlyingRawSecurity.getRawData());
     @SuppressWarnings("unchecked")
     List<FactorExposureData> factorExposureDataList =
         OpenGammaFudgeContext.getInstance().fromFudgeMsg(List.class, factorIdMsg.getMessage());
     return factorExposureDataList;
   } else {
     throw new OpenGammaRuntimeException(
         "Couldn't find factor list security " + securityEntryData.getFactorSetId());
   }
 }
コード例 #7
0
 @Override
 public List<ExternalId> visitSwaptionSecurity(final SwaptionSecurity security) {
   final List<ExternalId> result = new ArrayList<>();
   final SwapSecurity underlyingSwap =
       (SwapSecurity)
           _securitySource.getSingle(
               ExternalIdBundle.of(security.getUnderlyingId())); // TODO version
   final SwapLeg payLeg = underlyingSwap.getPayLeg();
   final SwapLeg receiveLeg = underlyingSwap.getReceiveLeg();
   final String securityType = security.getSecurityType();
   if (payLeg.getRegionId().equals(receiveLeg.getRegionId())) {
     return Arrays.asList(
         ExternalId.of(SECURITY_IDENTIFIER, securityType + "_" + payLeg.getRegionId().getValue()));
   }
   result.add(
       ExternalId.of(SECURITY_IDENTIFIER, securityType + "_" + payLeg.getRegionId().getValue()));
   result.add(
       ExternalId.of(
           SECURITY_IDENTIFIER, securityType + "_" + receiveLeg.getRegionId().getValue()));
   return result;
 }