Package com.opengamma.id

Examples of com.opengamma.id.ExternalIdBundle


    final LocalDate endDate = DateConstraint.evaluate(executionContext, desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.END_DATE_PROPERTY));
    final boolean includeEnd = HistoricalTimeSeriesFunctionUtils.parseBoolean(desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.INCLUDE_END_PROPERTY));
    final CurveSpecification curve = (CurveSpecification) inputs.getAllValues().iterator().next().getValue();
    final HistoricalTimeSeriesBundle bundle = new HistoricalTimeSeriesBundle();
    for (final CurveNodeWithIdentifier node : curve.getNodes()) {
      ExternalIdBundle id = ExternalIdBundle.of(node.getIdentifier());
      String dataField = node.getDataField();
      HistoricalTimeSeries timeSeries = timeSeriesSource.getHistoricalTimeSeries(dataField, id, resolutionKey, startDate, includeStart, endDate, includeEnd);
      if (timeSeries != null) {
        if (timeSeries.getTimeSeries().isEmpty()) {
          s_logger.info("Time series for {} is empty", id);
        } else {
          bundle.add(dataField, id, timeSeries);
        }
      } else {
        s_logger.info("Couldn't get time series for {}", id);
      }
      if (node instanceof PointsCurveNodeWithIdentifier) {
        final PointsCurveNodeWithIdentifier pointsNode = (PointsCurveNodeWithIdentifier) node;
        id = ExternalIdBundle.of(pointsNode.getUnderlyingIdentifier());
        dataField = pointsNode.getUnderlyingDataField();
        timeSeries = timeSeriesSource.getHistoricalTimeSeries(dataField, id, resolutionKey, startDate, includeStart, endDate, includeEnd);
        if (timeSeries != null) {
          if (timeSeries.getTimeSeries().isEmpty()) {
            s_logger.info("Time series for {} is empty", id);
          } else {
            bundle.add(dataField, id, timeSeries);
          }
        } else {
          s_logger.info("Couldn't get time series for {}", id);
        }
      }
      if (node.getCurveNode() instanceof ZeroCouponInflationNode) {
        final ZeroCouponInflationNode inflationNode = (ZeroCouponInflationNode) node.getCurveNode();
        final ConventionSource conventionSource = OpenGammaExecutionContext.getConventionSource(executionContext);
        Convention convention = conventionSource.getConvention(inflationNode.getInflationLegConvention());
        if (convention == null) {
          throw new OpenGammaRuntimeException("Convention with id " + inflationNode.getInflationLegConvention() + " was null");
        }
        if (!(convention instanceof InflationLegConvention)) {
          throw new OpenGammaRuntimeException("Cannot handle convention type " + convention.getClass());
        }
        final InflationLegConvention inflationLegConvention = (InflationLegConvention) convention;
        convention = conventionSource.getConvention(inflationLegConvention.getPriceIndexConvention());
        if (convention == null) {
          throw new OpenGammaRuntimeException("Convention with id " + inflationLegConvention.getPriceIndexConvention() + " was null");
        }
        if (!(convention instanceof PriceIndexConvention)) {
          throw new OpenGammaRuntimeException("Cannot handle convention type " + convention.getClass());
        }
        final String priceIndexField = MarketDataRequirementNames.MARKET_VALUE; //TODO
        final ExternalIdBundle priceIndexId = ExternalIdBundle.of(((PriceIndexConvention) convention).getPriceIndexId());
        final HistoricalTimeSeries priceIndexSeries = timeSeriesSource.getHistoricalTimeSeries(priceIndexField, priceIndexId, resolutionKey, startDate, includeStart, endDate, true);
        if (priceIndexSeries != null) {
          if (priceIndexSeries.getTimeSeries().isEmpty()) {
            s_logger.info("Time series for {} is empty", priceIndexId);
          } else {
View Full Code Here


      for (final ComputedValue value : inputs.getAllValues()) {
        if (!(value.getValue() instanceof Double)) {
          continue;
        }
        final Double dValue = (Double) value.getValue();
        final ExternalIdBundle identifiers = value.getSpecification().getTargetSpecification().accept(resolver);
        final VolatilityPoint volatilityPoint;
        final Pair<Tenor, Tenor> strikePoint;
        if (value.getSpecification().getValueName() == MarketDataRequirementNames.MARKET_VALUE) {
          volatilityPoint = getByIdentifier(_pointsById, identifiers);
          strikePoint = getByIdentifier(_strikesById, identifiers);
        } else {
          volatilityPoint = null;
          strikePoint = null;
        }
        if (volatilityPoint == null && strikePoint == null) {
          otherData.setDataPoint(identifiers, dValue);
        } else if (volatilityPoint != null && strikePoint == null) {
          if (volatilityPoint.getRelativeStrike() > -50) {
            final Double previous = dataPoints.put(volatilityPoint, dValue);
            final ExternalIdBundle previousIds = dataIds.put(volatilityPoint, identifiers);
            final Double previousRelativeStrike = relativeStrikes.put(volatilityPoint, volatilityPoint.getRelativeStrike());
            if (previous != null && previous > dValue) {
              //TODO: this is a hack because we don't understand which tickers are for straddles, so we presume that the straddle has lower vol
              dataPoints.put(volatilityPoint, previous);
              dataIds.put(volatilityPoint, previousIds);
View Full Code Here

    final LocalDate endDate = DateConstraint.evaluate(executionContext, endDateString);
    final boolean includeEnd = HistoricalTimeSeriesFunctionUtils.parseBoolean(desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.INCLUDE_END_PROPERTY));
    final HistoricalTimeSeriesBundle bundle = new HistoricalTimeSeriesBundle();
    final Set<CurveNodeWithIdentifier> nodes = curveSpecification.getNodes();
    for (final CurveNodeWithIdentifier node : nodes) {
      final ExternalIdBundle identifier = ExternalIdBundle.of(node.getIdentifier());
      final HistoricalTimeSeries timeSeries = timeSeriesSource.getHistoricalTimeSeries(dataField, identifier, resolutionKey, startDate, includeStart, endDate, includeEnd);
      if (timeSeries != null) {
        bundle.add(dataField, identifier, timeSeries);
      } else {
        s_logger.warn("Could not get time series for {}", identifier);
View Full Code Here

        final ValueRequirement specRequirement = new ValueRequirement(ValueRequirementNames.CURVE_SPECIFICATION, targetSpec, properties);
        final HistoricalTimeSeriesBundle bundleForCurve = (HistoricalTimeSeriesBundle) inputs.getValue(bundleRequirement);
        final CurveSpecification curveSpec = (CurveSpecification) inputs.getValue(specRequirement);
        for (final CurveNodeWithIdentifier node : curveSpec.getNodes()) {
          String dataField = node.getDataField();
          ExternalIdBundle ids = ExternalIdBundle.of(node.getIdentifier());
          HistoricalTimeSeries ts = bundleForCurve.get(dataField, ids);
          if (ts != null) {
            bundle.add(dataField, ids, bundleForCurve.get(dataField, ids));
          } else {
            s_logger.info("Could not get historical time series for {}", ids);
View Full Code Here

      if (field.getValue() instanceof FudgeMsg) {
        FudgeMsg deliverableContainer = (FudgeMsg) field.getValue();
        Double conversionFactor = deliverableContainer.getDouble("Conversion Factor");
        String buid = deliverableContainer.getString("Unique Bloomberg Identifier of Deliverable Bonds");
        if (conversionFactor != null && isValidField(buid)) {
          ExternalIdBundle ids = ExternalIdBundle.of(ExternalSchemes.bloombergBuidSecurityId(buid));
          BondFutureDeliverable deliverable = new BondFutureDeliverable(ids, conversionFactor);
          result.add(deliverable);
        }
      }
    }
View Full Code Here

   */
  private Map<ExternalId, HistoricalTimeSeriesInfoDocument> extractBuids(Iterable<HistoricalTimeSeriesInfoDocument> documents) {
    Map<ExternalId, HistoricalTimeSeriesInfoDocument> buids = Maps.newHashMap();
    for (HistoricalTimeSeriesInfoDocument doc : documents) {
      ExternalIdBundleWithDates identifierBundleWithDates = doc.getInfo().getExternalIdBundle();
      ExternalIdBundle bundle = identifierBundleWithDates.toBundle();
      ExternalId buid = bundle.getExternalId(ExternalSchemes.BLOOMBERG_BUID);
      if (buid == null) {
        throw new OpenGammaRuntimeException("no buid for " + bundle);
      }
      buids.put(buid, doc);
    }
View Full Code Here

    final FXForwardCurveSpecification specification = (FXForwardCurveSpecification) inputs.getValue(ValueRequirementNames.FX_FORWARD_CURVE_SPECIFICATION);
    final HistoricalTimeSeriesBundle bundle = new HistoricalTimeSeriesBundle();
    final Tenor[] tenors = definition.getTenors();
    final FXForwardCurveInstrumentProvider curveInstrumentProvider = specification.getCurveInstrumentProvider();
    for (final Tenor tenor : tenors) {
      final ExternalIdBundle id = ExternalIdBundle.of(curveInstrumentProvider.getInstrument(endDate, tenor));
      final HistoricalTimeSeries timeSeries = timeSeriesSource.getHistoricalTimeSeries(dataField, id, resolutionKey, startDate, includeStart, endDate, includeEnd);
      if (timeSeries != null) {
        if (timeSeries.getTimeSeries().isEmpty()) {
          s_logger.warn("Time series for {} is empty", id);
        } else {
          bundle.add(dataField, id, timeSeries);
        }
      } else {
        s_logger.warn("Couldn't get time series for {}", id);
      }
    }
    final ExternalIdBundle id = ExternalIdBundle.of(curveInstrumentProvider.getSpotInstrument());
    final HistoricalTimeSeries timeSeries = timeSeriesSource.getHistoricalTimeSeries(dataField, id, resolutionKey, startDate, includeStart, endDate, includeEnd);
    if (timeSeries != null) {
      if (timeSeries.getTimeSeries().isEmpty()) {
        s_logger.warn("Time series for {} is empty", id);
      } else {
View Full Code Here

        s_logger.warn("Unable to load security type {} mapped from {} as no loader is registered", secType, bbgkeys);
        continue;
      }
      Map<String, ManageableSecurity> securities = loader.loadSecurities(bbgkeys);
      for (Entry<String, ManageableSecurity> secEntry : securities.entrySet()) {
        ExternalIdBundle identifierBundle = bundle2Bbgkey.get(secEntry.getKey());
        result.put(identifierBundle, secEntry.getValue());
      }
    }
    return result;
  }
View Full Code Here

public class NonVersionedRedisConfigSourceTest extends AbstractRedisTestCase {
 
  public void putDeleteGetAll() {
    NonVersionedRedisConfigSource configSource = new NonVersionedRedisConfigSource(getJedisPool(), getRedisPrefix());
   
    ExternalIdBundle bundle1 = constructIdBundle("Test", "1");
    ExternalIdBundle bundle2 = constructIdBundle("Test", "2");
    ExternalIdBundle bundle3 = constructIdBundle("Test", "3");
    ExternalIdBundle bundle4 = constructIdBundle("Test", "4");
    ExternalIdBundle bundle5 = constructIdBundle("Test", "5");
    configSource.put(ExternalIdBundle.class, "bundle-1", bundle1);
    configSource.put(ExternalIdBundle.class, "bundle-2", bundle2);
    configSource.put(ExternalIdBundle.class, "bundle-3", bundle3);
    configSource.put(ExternalIdBundle.class, "bundle-4", bundle4);
    configSource.put(ExternalIdBundle.class, "bundle-5", bundle5);
View Full Code Here

  }
 
  public void putGet() {
    NonVersionedRedisConfigSource configSource = new NonVersionedRedisConfigSource(getJedisPool(), getRedisPrefix());
   
    ExternalIdBundle bundle1 = constructIdBundle("Test", "1");
    ExternalIdBundle bundle2 = constructIdBundle("Test", "2");
    ExternalIdBundle bundle3 = constructIdBundle("Test", "3");
    ExternalIdBundle bundle4 = constructIdBundle("Test", "4");
    ExternalIdBundle bundle5 = constructIdBundle("Test", "5");
    configSource.put(ExternalIdBundle.class, "bundle-1", bundle1);
    configSource.put(ExternalIdBundle.class, "bundle-2", bundle2);
    configSource.put(ExternalIdBundle.class, "bundle-3", bundle3);
    configSource.put(ExternalIdBundle.class, "bundle-4", bundle4);
    configSource.put(ExternalIdBundle.class, "bundle-5", bundle5);
   
    ExternalIdBundle result = null;
   
    result = configSource.getLatestByName(ExternalIdBundle.class, "bundle-2");
    assertNotNull(result);
    assertEquals("2", result.getValue(ExternalScheme.of("Test")));
  }
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.