Package com.opengamma.id

Examples of com.opengamma.id.ExternalId


      if (targetReference instanceof ComputationTargetRequirement) {
        ComputationTargetRequirement requirement = (ComputationTargetRequirement) targetReference;
        Set<ExternalId> externalIds = requirement.getIdentifiers().getExternalIds();
        ArgumentChecker.isTrue(externalIds.size() == 1, "One (and only one) external id must be specified currently.");
        ExternalId externalId = Iterables.get(externalIds, 0);
        uri = DependencyGraphTraceProviderResource.uriValueRequirementByExternalId(uri, constrainedValueName, targetType, externalId);
      } else if (targetReference instanceof ComputationTargetSpecification) {
        UniqueId uniqueId = ((ComputationTargetSpecification) targetReference).getUniqueId();
        uri = DependencyGraphTraceProviderResource.uriValueRequirementByUniqueId(uri, constrainedValueName, targetType, uniqueId);
      } else {
View Full Code Here


    clone.setExternalIdBundle(clone.getExternalIdBundle().withoutScheme(getScheme()));
    ExternalIdBundle identifiers = _securities.get(clone);
    if (identifiers != null) {
      return identifiers;
    }
    final ExternalId guid = ExternalId.of(getScheme(), createGuid());
    identifiers = security.getExternalIdBundle().withExternalId(guid);
    security.setExternalIdBundle(identifiers);
    _securities.put(clone, identifiers);
    storeSecurityImpl(security);
    return identifiers;
View Full Code Here

  private ExternalId getSwapRateFor(Currency ccy, LocalDate tradeDate, Tenor maturityTenor, Tenor forwardTenor) {
    final CurveSpecificationBuilderConfiguration curveSpecConfig = getCurrencyCurveConfig(ccy);
    if (curveSpecConfig == null) {
      return null;
    }
    final ExternalId swapSecurity;
    final Tenor tenor;
    final int months = (int) maturityTenor.getPeriod().toTotalMonths() + (int) forwardTenor.getPeriod().toTotalMonths();
    if (months < 12) {
      tenor = Tenor.ofMonths(months);
    } else {
View Full Code Here

    if (liborConvention == null) {
      s_logger.error("Couldn't get libor convention for {}", swapConvention.getSwapFloatingLegInitialRate());
      return null;
    }
    // look up the rate timeseries identifier out of the bundle
    final ExternalId tsIdentifier = getTimeSeriesIdentifier(liborConvention);
    // look up the value on our chosen trade date
    final HistoricalTimeSeries initialRateSeries = getHistoricalSource().getHistoricalTimeSeries(MarketDataRequirementNames.MARKET_VALUE, tsIdentifier.toBundle(), null, tradeDate.toLocalDate(),
        true, tradeDate.toLocalDate(), true);
    if (initialRateSeries == null || initialRateSeries.getTimeSeries().isEmpty()) {
      s_logger.error("couldn't get series for {} on {}", tsIdentifier, tradeDate);
      return null;
    }
    Double initialRate = initialRateSeries.getTimeSeries().getEarliestValue();
    // get the identifier for the swap rate for the maturity we're interested in (assuming the fixed rate will be =~ swap rate)
    final ExternalId swapRateForMaturityIdentifier = getSwapRateFor(ccy, tradeDate.toLocalDate(), maturity, forward);
    if (swapRateForMaturityIdentifier == null) {
      s_logger.error("Couldn't get swap rate identifier for {} [{}] from {}", new Object[] {ccy, maturity, tradeDate });
      return null;
    }
    final HistoricalTimeSeries fixedRateSeries = getHistoricalSource().getHistoricalTimeSeries(MarketDataRequirementNames.MARKET_VALUE, swapRateForMaturityIdentifier.toBundle(),
        null, tradeDate.toLocalDate(), true,
        tradeDate.toLocalDate(), true);
    if (fixedRateSeries == null) {
      s_logger.error("can't find time series for {} on {}", swapRateForMaturityIdentifier, tradeDate);
      return null;
View Full Code Here

    return msg;
  }

  @Override
  public SecurityEntryData buildObject(FudgeDeserializer deserializer, FudgeMsg msg) {
    ExternalId id = ExternalId.parse(msg.getString(EXTERNAL_ID_FIELD_NAME));
    Currency currency = Currency.of(msg.getString(CURRENCY_FIELD_NAME));
    LocalDate maturityDate = msg.getValue(LocalDate.class, MATURITY_DATE_FIELD_NAME);
    ExternalId factorSetId = ExternalId.parse(msg.getString(FACTOR_SET_EXTERNAL_ID_FIELD_NAME));
   
    SecurityEntryData data = new SecurityEntryData(id, currency, maturityDate, factorSetId);
    return data;
  }
View Full Code Here

    }
    if (!isValidField(category)) {
      s_logger.info("category is null, cannot construct EquityFutureSecurity");
      return null;
    }
    ExternalId underlying = null;
    if (underlyingTicker != null) {
      underlying = ExternalSchemes.bloombergTickerSecurityId(underlyingTicker + " " + marketSector);
    }

    Currency currency = Currency.parse(currencyStr);
View Full Code Here

  }

  @Override
  public InstrumentDefinition<?> visitSwaptionSecurity(final SwaptionSecurity swaptionSecurity) {
    ArgumentChecker.notNull(swaptionSecurity, "swaption security");
    final ExternalId underlyingIdentifier = swaptionSecurity.getUnderlyingId();
    final ZonedDateTime expiry = swaptionSecurity.getExpiry().getExpiry();
    final InstrumentDefinition<?> underlyingSwap = ((SwapSecurity) _securitySource.getSingle(ExternalIdBundle.of(underlyingIdentifier))).accept(_swapConverter);
    final SwapDefinition swapDefinition = (SwapDefinition) underlyingSwap;
    final boolean isCashSettled = swaptionSecurity.isCashSettled();
    final boolean isLong = swaptionSecurity.isLong();
View Full Code Here

              requirementTarget = targetSpec;
            }
          } else if (constraintValues.contains(TARGET_SPECIFICATION_EXTERNAL)) {
            final ExternalIdBundle identifiers;
            if (target.getValue() instanceof ExternalIdentifiable) {
              final ExternalId identifier = ((ExternalIdentifiable) target.getValue()).getExternalId();
              if (identifier == null) {
                identifiers = ExternalIdBundle.EMPTY;
              } else {
                identifiers = identifier.toBundle();
              }
            } else if (target.getValue() instanceof ExternalBundleIdentifiable) {
              identifiers = ((ExternalBundleIdentifiable) target.getValue()).getExternalIdBundle();
            } else if (target.getValue() == null) {
              // Null - special case
View Full Code Here

  }

  private Set<ExternalIdBundle> loadOptionIdentifiers(final Set<ExternalIdBundle> identifiers) {
    Set<String> bloombergKeys = new HashSet<String>();
    for (ExternalIdBundle dsids : identifiers) {
      ExternalId preferredIdentifier = BloombergDomainIdentifierResolver.resolvePreferredIdentifier(dsids);
      bloombergKeys.add(BloombergDomainIdentifierResolver.toBloombergKey(preferredIdentifier));
    }

    Set<ExternalIdBundle> optionsIdentifiers = new HashSet<ExternalIdBundle>();
    Map<String, FudgeMsg> refDataResultMap = _refDataProvider.getReferenceDataIgnoreCache(bloombergKeys, Collections.singleton(FIELD_OPT_CHAIN));
    for (Entry<String, FudgeMsg> entry : refDataResultMap.entrySet()) {
      FudgeMsg fieldContainer = entry.getValue();
      //process the options
      int nAdded = 0;
      for (FudgeField field : fieldContainer.getAllByName(BloombergConstants.FIELD_OPT_CHAIN)) {
        FudgeMsg optionContainer = (FudgeMsg) field.getValue();
        String optionTickerStr = optionContainer.getString("Security Description");
        String expiryStr = ReferenceDataProviderUtils.singleFieldSearchIgnoreCache(optionTickerStr, FIELD_OPT_EXPIRE_DT, _refDataProvider);
        LocalDate expiryLocalDate = null;
        try {
          expiryLocalDate = LocalDate.parse(expiryStr);
        } catch (Exception e) {
          throw new OpenGammaRuntimeException(expiryStr + " returned from bloomberg not in format yyyy-mm-dd", e);
        }
        int year = expiryLocalDate.getYear();
        int month = expiryLocalDate.getMonthValue();
        int day = expiryLocalDate.getDayOfMonth();
        Expiry expiry = new Expiry(DateUtils.getUTCDate(year, month, day));

        if (expiry.getExpiry().toInstant().toEpochMilli() < (System.currentTimeMillis() + (25L * 60L * 60L * 1000L))) {
          s_logger.info("Option {} in future, so passing on it.", optionTickerStr);
          continue;
        }

        ExternalId optionTicker = ExternalSchemes.bloombergTickerSecurityId(optionTickerStr);
        optionsIdentifiers.add(ExternalIdBundle.of(optionTicker));

        nAdded++;
        if (nAdded >= _optionSize) {
          break;
View Full Code Here

   
    assertNotNull(position.getQuantity());
    assertEquals(0, new BigDecimal(984).scaleByPowerOfTen(-1).compareTo(position.getQuantity()));
   
    assertEquals(1, position.getSecurityLink().getExternalId().size());
    ExternalId id = position.getSecurityLink().getExternalId().iterator().next();
    assertNotNull(id);
    assertNotNull(id.getScheme());
    assertEquals("KIRK", id.getScheme().getName());
    assertNotNull(id.getValue());
    assertEquals("MY-ID", id.getValue());
  }
View Full Code Here

TOP

Related Classes of com.opengamma.id.ExternalId

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.