コード例 #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> 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()));
 }