Package com.opengamma.id

Examples of com.opengamma.id.ExternalIdBundle


    SecuritySearchRequest searchRequest = new SecuritySearchRequest();
    searchRequest.setExternalIdSearch(new ExternalIdSearch(underlyingId));
    SecuritySearchResult searchResult = _securityMaster.search(searchRequest);
    ManageableSecurity underlying = searchResult.getSingleSecurity();
    ExternalIdBundle underlyingBundle = underlying.getExternalIdBundle();
    // this isn't part of the equality check below because the test swaption can't know what the ID will be
    assertTrue(underlyingBundle.contains(underlyingId));
    // clear these values so we can do an equality check with the test swaption
    underlying.setUniqueId(null);
    underlying.setExternalIdBundle(ExternalIdBundle.EMPTY);
    assertEquals(BlotterTestUtils.SWAP, underlying);
  }
View Full Code Here


    ManageableSecurity underlyingSecurity = null;
    if (includeUnderlying) {
      underlyingSecurity = getOrLoadEquity(ticker);
    }

    final ExternalIdBundle bundle = underlyingSecurity == null ? ExternalIdBundle.of(ticker) : underlyingSecurity.getExternalIdBundle();
    final HistoricalTimeSeriesInfoDocument timeSeriesInfo = getOrLoadTimeSeries(ticker, bundle);
    final double estimatedCurrentStrike = getOrLoadMostRecentPoint(timeSeriesInfo);
    final Set<ExternalId> optionChain = getOptionChain(ticker);

    //TODO: reuse positions/nodes?
View Full Code Here

    return getOrLoadTimeSeries(ticker, ExternalIdBundle.of(ticker));
  }

  private HistoricalTimeSeriesInfoDocument getOrLoadTimeSeries(final ExternalId ticker, final ExternalIdBundle idBundle) {

    final ExternalIdBundle searchBundle = idBundle.withoutScheme(ExternalSchemes.ISIN); //For things which move country, e.g. ISIN(VALE5 BZ Equity) == ISIN(RIODF US Equity)
    final HistoricalTimeSeriesInfoSearchRequest htsRequest = new HistoricalTimeSeriesInfoSearchRequest(searchBundle);
    htsRequest.setDataField("PX_LAST");
    final HistoricalTimeSeriesInfoSearchResult htsSearch = getToolContext().getHistoricalTimeSeriesMaster().search(htsRequest);
    switch (htsSearch.getDocuments().size()) {
      case 0:
View Full Code Here

      for (final String key : map.keySet()) {
        final String buid = referenceDataProvider.getReferenceDataValue(key, BloombergConstants.FIELD_ID_BBG_UNIQUE);
        idBundle = idBundle.withExternalId(ExternalSchemes.bloombergBuidSecurityId(buid));
      }
    }
    final ExternalIdBundle searchBundle = idBundle.withoutScheme(ExternalSchemes.ISIN); // For things which move country, e.g. ISIN(VALE5 BZ Equity) == ISIN(RIODF US Equity)
    final Map<ExternalId, UniqueId> timeSeries = getToolContext().getHistoricalTimeSeriesLoader()
        .loadTimeSeries(searchBundle.getExternalIds(), "UNKNOWN", "PX_LAST", LocalDate.now().minusYears(1), null);
    if (timeSeries.size() != 1) {
      throw new OpenGammaRuntimeException("Failed to load time series " + idBundle + " " + timeSeries);
    }
    for (final UniqueId uid : timeSeries.values()) {
      return getToolContext().getHistoricalTimeSeriesMaster().get(uid);
View Full Code Here

    final HistoricalTimeSeriesInfoDocument newUid = getToolContext().getHistoricalTimeSeriesMaster().get(timeSeries.getUniqueId().toLatest());
    return getToolContext().getHistoricalTimeSeriesSource().getHistoricalTimeSeries(newUid.getUniqueId());
  }

  private HistoricalTimeSeriesInfoDocument loadTimeSeries(final HistoricalTimeSeriesInfoDocument timeSeriesInfo) {
    final ExternalIdBundle idBundle = timeSeriesInfo.getInfo().getExternalIdBundle().toBundle(LocalDate.now());
    return loadTimeSeries(idBundle);
  }
View Full Code Here

        return underlyingSearch.getFirstSecurity();
    }
  }

  private ManageableSecurity loadSecurity(final ExternalId ticker) {
    final ExternalIdBundle tickerBundle = ExternalIdBundle.of(ticker);
    final Collection<ExternalIdBundle> bundles = Collections.singleton(tickerBundle);
    final Map<ExternalIdBundle, UniqueId> loaded = getToolContext().getSecurityLoader().loadSecurities(bundles);
    final UniqueId loadedSec = loaded.get(tickerBundle);
    if (loadedSec == null) {
      throw new OpenGammaRuntimeException("Failed to load security for " + ticker);
View Full Code Here

  public static double getFXMultiplier(final Object id, final double multiplier) {
    if (id instanceof ExternalId) {
      return getFXMultiplierFromExternalId((ExternalId) id, multiplier);
    } else if (id instanceof ExternalIdBundle) {
      final ExternalIdBundle bundle = (ExternalIdBundle) id;
      if (bundle.getExternalId(ExternalSchemes.BLOOMBERG_TICKER) != null) {
        return getFXMultiplierFromExternalId(bundle.getExternalId(ExternalSchemes.BLOOMBERG_TICKER), multiplier);
      } else if (bundle.getExternalId(ExternalSchemes.BLOOMBERG_TICKER_WEAK) != null) {
        return getFXMultiplierFromExternalId(bundle.getExternalId(ExternalSchemes.BLOOMBERG_TICKER_WEAK), multiplier);
      }
    } else if (id instanceof UniqueId) {
      final UniqueId uid = (UniqueId) id;
      return getFXMultiplierFromExternalId(ExternalId.of(ExternalSchemes.BLOOMBERG_TICKER, uid.getValue()), multiplier);
    }
View Full Code Here

  public static boolean isFXRate(final Object id) {
    if (id instanceof ExternalId) {
      return isFXRateFromBloombergTicker((ExternalId) id);
    } else if (id instanceof ExternalIdBundle) {
      final ExternalIdBundle bundle = (ExternalIdBundle) id;
      if (bundle.getExternalId(ExternalSchemes.BLOOMBERG_TICKER) != null) {
        return isFXRateFromBloombergTicker(bundle.getExternalId(ExternalSchemes.BLOOMBERG_TICKER));
      } else if (bundle.getExternalId(ExternalSchemes.BLOOMBERG_TICKER_WEAK) != null) {
        return isFXRateFromBloombergTicker(bundle.getExternalId(ExternalSchemes.BLOOMBERG_TICKER_WEAK));
      }
    } else if (id instanceof UniqueId) {
      final UniqueId uid = (UniqueId) id;
      return isFXRateFromBloombergTicker(ExternalId.of(ExternalSchemes.BLOOMBERG_TICKER, uid.getValue()));
    }
View Full Code Here

      final ComputationTargetReference targetSpec = valueRequirement.getTargetReference();
      // Only shift equities
      if (targetSpec.getType().isTargetType(ComputationTargetType.SECURITY) || !MarketDataRequirementNames.MARKET_VALUE.equals(valueRequirement.getValueName())) {
        return value;
      }
      final ExternalIdBundle bundle = targetSpec.accept(new ComputationTargetReferenceVisitor<ExternalIdBundle>() {

        @Override
        public ExternalIdBundle visitComputationTargetRequirement(final ComputationTargetRequirement requirement) {
          return requirement.getIdentifiers();
        }

        @Override
        public ExternalIdBundle visitComputationTargetSpecification(final ComputationTargetSpecification specification) {
          try {
            return getSecuritySource().get(specification.getUniqueId()).getExternalIdBundle();
          } catch (final DataNotFoundException ex) {
            return null;
          }
        }

      });
      if ((bundle == null) || !bundle.getValue(ExternalSchemes.BLOOMBERG_TICKER).contains("Equity")) {
        return value;
      }
      if (value instanceof Number) {
        return ((Number) value).doubleValue() * _shift;
      } else if (value instanceof MissingInput) {
View Full Code Here

    assertEquals(null, test.getCorrectionToInstant());
    ManageablePosition testPosition = test.getPosition();
    assertNotNull(testPosition);
    assertEquals(uniqueId, testPosition.getUniqueId());
    assertEquals(BigDecimal.TEN, testPosition.getQuantity());
    ExternalIdBundle secKey = testPosition.getSecurityLink().getExternalId();
    assertEquals(1, secKey.size());
    assertTrue(secKey.getExternalIds().contains(ExternalId.of("A", "B")));
  }
View Full Code Here

TOP

Related Classes of com.opengamma.id.ExternalIdBundle

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.