Package com.opengamma.id

Examples of com.opengamma.id.ExternalScheme


   */
  public static String getIndexOrEquityName(final ExternalId externalId) {
    //FIXME: Modify to take ExternalId to avoid incorrect cast to UniqueId
    ArgumentChecker.notNull(externalId, "unique id");
    final String value = externalId.getValue();
    final ExternalScheme extScheme = externalId.getScheme();

    if (extScheme.equals(ExternalSchemes.BLOOMBERG_BUID) || extScheme.equals(ExternalSchemes.BLOOMBERG_BUID_WEAK)) {
      final int length = value.length();
      return value.substring(length - 3, length).toUpperCase(); //TODO fix this
    }
    if (extScheme.equals(ExternalSchemes.BLOOMBERG_TICKER) || extScheme.equals(ExternalSchemes.BLOOMBERG_TICKER_WEAK)) {
      final int lastSpace = value.lastIndexOf(" ");
      return value.substring(0, lastSpace);
    }
    if (extScheme.equals(ExternalSchemes.ACTIVFEED_TICKER)) {
      final int firstDot = value.indexOf(".", 0);
      return value.substring(0, firstDot + 1); // e.g. "IBM."
    }
    s_logger.info("Cannot handle scheme of type {}", extScheme);
    return null;
View Full Code Here


   * @param surfaceName the surface or curve name
   * @return the scheme
   */
  //TODO: This should be moved somewhere non equity specific
  public static ExternalScheme getTargetType(final String surfaceName) {
    final ExternalScheme target = SCHEME_MAPPING.get(surfaceName);
    if (target == null) {
      s_logger.warn("Can't determine data scheme from surface/curve name: " + surfaceName);
      return null;
    }
    return target;
View Full Code Here

   *
   * @param scheme the destination scheme
   * @return the source scheme
   */
  public static ExternalScheme getRemappedScheme(final ExternalScheme scheme) {
    final ExternalScheme remappedScheme = SCHEME_REMAPPING.get(scheme);
    if (remappedScheme == null) {
      return scheme; //no remapping
    }
    return remappedScheme;
  }
View Full Code Here

    requirements.add(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE, ComputationTargetType.PRIMITIVE, parameters.getFirstInitialVolatilityId()));
    requirements.add(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE, ComputationTargetType.PRIMITIVE, parameters.getSecondInitialVolatilityId()));
    requirements.add(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE, ComputationTargetType.PRIMITIVE, parameters.getCorrelationId()));
    final Map<Tenor, Pair<ExternalId, ExternalId>> volatilityTermStructure = parameters.getVolatilityTermStructure();
    for (final Map.Entry<Tenor, Pair<ExternalId, ExternalId>> entry : volatilityTermStructure.entrySet()) {
      final ExternalScheme firstScheme = entry.getValue().getFirst().getScheme();
      final ExternalScheme secondScheme = entry.getValue().getSecond().getScheme();
      final String firstId = entry.getValue().getFirst().getValue();
      final String secondId = entry.getValue().getSecond().getValue();
      final ExternalId firstTenorAppendedId = ExternalId.of(firstScheme, createId(entry.getKey(), firstId));
      final ExternalId secondTenorAppendedId = ExternalId.of(secondScheme, createId(entry.getKey(), secondId));
      requirements.add(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE, ComputationTargetType.PRIMITIVE, firstTenorAppendedId));
      requirements.add(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE, ComputationTargetType.PRIMITIVE, secondTenorAppendedId));
    }
    final ZonedDateTime atZDT = ZonedDateTime.ofInstant(atInstant, ZoneOffset.UTC);
    return new AbstractInvokingCompiledFunction(atZDT.with(LocalTime.MIDNIGHT), atZDT.plusDays(1).with(LocalTime.MIDNIGHT).minusNanos(1000000)) {

      @Override
      public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target,
          final Set<ValueRequirement> desiredValues) throws AsynchronousExecution {
        final Clock snapshotClock = executionContext.getValuationClock();
        final ZonedDateTime now = ZonedDateTime.now(snapshotClock);
        final Object firstMeanReversionObject = inputs.getValue(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE,
            ComputationTargetType.PRIMITIVE, parameters.getFirstMeanReversionId()));
        if (firstMeanReversionObject == null) {
          throw new OpenGammaRuntimeException("Could not get first mean reversion value");
        }
        final Object secondMeanReversionObject = inputs.getValue(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE,
            ComputationTargetType.PRIMITIVE, parameters.getSecondMeanReversionId()));
        if (secondMeanReversionObject == null) {
          throw new OpenGammaRuntimeException("Could not get second mean reversion value");
        }
        final Object firstInitialVolatilityObject = inputs.getValue(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE,
            ComputationTargetType.PRIMITIVE, parameters.getFirstInitialVolatilityId()));
        if (firstInitialVolatilityObject == null) {
          throw new OpenGammaRuntimeException("Could not get first initial volatility value");
        }
        final Object secondInitialVolatilityObject = inputs.getValue(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE,
            ComputationTargetType.PRIMITIVE, parameters.getSecondInitialVolatilityId()));
        if (secondInitialVolatilityObject == null) {
          throw new OpenGammaRuntimeException("Could not get second initial volatility value");
        }
        final Object correlationObject = inputs.getValue(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE,
            ComputationTargetType.PRIMITIVE, parameters.getCorrelationId()));
        if (correlationObject == null) {
          throw new OpenGammaRuntimeException("Could not get correlation value");
        }
        final Double firstMeanReversion = (Double) firstMeanReversionObject;
        final Double secondMeanReversion = (Double) secondMeanReversionObject;
        final Double firstInitialVolatility = (Double) firstInitialVolatilityObject;
        final Double secondInitialVolatility = (Double) secondInitialVolatilityObject;
        final Double correlation = (Double) correlationObject;
        final DoubleArrayList firstVolatility = new DoubleArrayList();
        firstVolatility.add(firstInitialVolatility);
        final DoubleArrayList secondVolatility = new DoubleArrayList();
        secondVolatility.add(secondInitialVolatility);
        final DoubleArrayList volatilityTime = new DoubleArrayList();
        for (final Map.Entry<Tenor, Pair<ExternalId, ExternalId>> entry : volatilityTermStructure.entrySet()) {
          final ExternalScheme firstScheme = entry.getValue().getFirst().getScheme();
          final ExternalScheme secondScheme = entry.getValue().getSecond().getScheme();
          final String firstId = entry.getValue().getFirst().getValue();
          final String secondId = entry.getValue().getSecond().getValue();
          final ExternalId firstTenorAppendedId = ExternalId.of(firstScheme, createId(entry.getKey(), firstId));
          final ExternalId secondTenorAppendedId = ExternalId.of(secondScheme, createId(entry.getKey(), secondId));
          final Object firstVolatilityObject = inputs.getValue(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE,
View Full Code Here

    //return BlackVolatilitySurfacePropertyUtils.getSurfaceRequirement(desiredValue, additionalConstraints, surfaceName, forwardCurveName,
    //InstrumentTypeProperties.EQUITY_OPTION, ComputationTargetType.PRIMITIVE, underlyingBuid);
  }

  private ExternalId getWeakUnderlyingId(final ExternalId underlyingId, final HistoricalTimeSeriesSource tsSource, final SecuritySource securitySource, final String surfaceName) {
    /** scheme we return i.e. BBG_WEAK */
    final ExternalScheme desiredScheme = EquitySecurityUtils.getTargetType(surfaceName);
    /** scheme we look for i.e. BBG */
    final ExternalScheme sourceScheme = EquitySecurityUtils.getRemappedScheme(desiredScheme);
    if (desiredScheme == null) { // surface name is unknown
      return null;
    }
    if (underlyingId.isScheme(desiredScheme)) {
View Full Code Here

   * @return the Bloomberg key, not null
   */
  public static String toBloombergKey(ExternalId externalId) {
    ArgumentChecker.notNull(externalId, "externalId");
   
    ExternalScheme scheme = externalId.getScheme();
    if (SCHEME_MAP.containsKey(scheme)) {
      String prefix = SCHEME_MAP.get(scheme);
      String id  = externalId.getValue();
      return prefix != null ? prefix + id : id;
    }
View Full Code Here

    ArgumentChecker.notNull(externalId, "externalId");
    if (dataProvider == null || dataProvider.contains(DATA_PROVIDER_UNKNOWN) || dataProvider.equalsIgnoreCase(DEFAULT_DATA_PROVIDER)) {
      return toBloombergKey(externalId);
    }
   
    ExternalScheme scheme = externalId.getScheme();
    if (SCHEME_MAP.containsKey(scheme)) {
      String prefix = SCHEME_MAP.get(scheme);
      StringBuilder buf = new StringBuilder();
      if (prefix != null) {
        buf.append(prefix);
      }
      if (scheme.equals(ExternalSchemes.BLOOMBERG_TICKER)) {
        String id  = externalId.getValue().toUpperCase(Locale.US);
        if (id.endsWith("EQUITY")) {
          buf.append(id);
        } else {
          String[] splits = id.split(" ");
View Full Code Here

        return simpleExchange;
      }
    });
    EHCachingExchangeSource source = new EHCachingExchangeSource(underlying, _cacheManager);
    assertEquals(0, getCount.get());
    ExternalScheme scheme = ExternalScheme.of("Scheme");
    ExternalId id = ExternalId.of(scheme, "Value");
    Exchange get1 = source.getSingle(id);
    assertEquals(1, getCount.get());
    assertEquals(1, get1.getExternalIdBundle().size());
    assertEquals(id, get1.getExternalIdBundle().getExternalId(scheme));
View Full Code Here

TOP

Related Classes of com.opengamma.id.ExternalScheme

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.