Examples of ManageableHistoricalTimeSeriesInfo


Examples of com.opengamma.master.historicaltimeseries.ManageableHistoricalTimeSeriesInfo

    int toUpdate = 0;
    for (HistoricalTimeSeriesInfoDocument doc : documents) {
      if (++i % 100 == 0) {
        s_logger.info("Checking required updates for time series {} of {} ", i, documents.size());
      }
      ManageableHistoricalTimeSeriesInfo info = doc.getInfo();
      ExternalIdBundle idBundle = info.getExternalIdBundle().toBundle();
     
      // select start date
      LocalDate startDate = _startDate;
      if (startDate == null) {
        // lookup start date as one day after the latest point in the series
        UniqueId htsId = doc.getInfo().getUniqueId();
        LocalDate latestDate = getLatestDate(htsId);
        if (isUpToDate(latestDate, doc.getInfo().getObservationTime())) {
          s_logger.debug("Not scheduling update for up to date series {} from {}", htsId, latestDate);
          continue// up to date, so do not fetch
        }
        s_logger.debug("Scheduling update for series {} from {}", htsId, latestDate);
        toUpdate++;
        startDate = DateUtils.nextWeekDay(latestDate);
      }
      Map<String, Map<String, Set<ExternalIdBundle>>> providerFieldIdentifiers = MapUtils.putIfAbsentGet(bbgTSRequest, startDate, new HashMap<String, Map<String, Set<ExternalIdBundle>>>());
     
      // select data provider
      String dataProvider = info.getDataProvider();
      Map<String, Set<ExternalIdBundle>> fieldIdentifiers = MapUtils.putIfAbsentGet(providerFieldIdentifiers, dataProvider, new HashMap<String, Set<ExternalIdBundle>>());
     
      // select data field
      String dataField = info.getDataField();
      Set<ExternalIdBundle> identifiers = MapUtils.putIfAbsentGet(fieldIdentifiers, dataField, new HashSet<ExternalIdBundle>());
     
      // store external id
      identifiers.add(idBundle);
     
View Full Code Here

Examples of com.opengamma.master.historicaltimeseries.ManageableHistoricalTimeSeriesInfo

  private List<HistoricalTimeSeriesInfoDocument> removeExpiredTimeSeries(final Iterable<HistoricalTimeSeriesInfoDocument> searchIterable) {
    List<HistoricalTimeSeriesInfoDocument> result = Lists.newArrayList();
    LocalDate previousWeekDay = DateUtils.previousWeekDay();
   
    for (HistoricalTimeSeriesInfoDocument htsInfoDoc : searchIterable) {
      ManageableHistoricalTimeSeriesInfo tsInfo = htsInfoDoc.getInfo();

      boolean valid = getIsValidOn(previousWeekDay, tsInfo);
      if (valid) {
        result.add(htsInfoDoc);
      } else {
        s_logger.debug("Time series {} is not valid on {}", tsInfo.getUniqueId(), previousWeekDay);
      }
    }
    return result;
  }
View Full Code Here

Examples of com.opengamma.master.historicaltimeseries.ManageableHistoricalTimeSeriesInfo

   * @return the best match, null if no match
   */
  private ManageableHistoricalTimeSeriesInfo bestMatch(Collection<ManageableHistoricalTimeSeriesInfo> matches, HistoricalTimeSeriesRating rating) {
    s_logger.debug("Find best match using rules: {}", rating);
    int currentScore = Integer.MIN_VALUE;
    ManageableHistoricalTimeSeriesInfo bestMatch = null;
    for (ManageableHistoricalTimeSeriesInfo match : matches) {
      int score = rating.rate(match);
      s_logger.debug("Score: {} for info: {}", score, match);
      if (score > currentScore) {
        currentScore = score;
View Full Code Here

Examples of com.opengamma.master.historicaltimeseries.ManageableHistoricalTimeSeriesInfo

      // update existing time series
      HistoricalTimeSeriesInfoDocument existingTsDoc = searchResult.getFirstDocument();
      return writeTimeSeries(description, dataSource, dataProvider, dataField, observationTime, existingTsDoc.getObjectId(), timeSeries);
    } else {
      // add new time series
      ManageableHistoricalTimeSeriesInfo info = new ManageableHistoricalTimeSeriesInfo();
      info.setDataField(dataField);
      info.setDataSource(dataSource);
      info.setDataProvider(dataProvider);
      info.setObservationTime(observationTime);
      info.setExternalIdBundle(ExternalIdBundleWithDates.of(externalIdBundle));
      info.setName(description);
      HistoricalTimeSeriesInfoDocument htsInfoDoc = new HistoricalTimeSeriesInfoDocument();
      htsInfoDoc.setInfo(info);
     
      HistoricalTimeSeriesInfoDocument addedInfoDoc = _htsMaster.add(htsInfoDoc);
      s_logger.debug("Adding time series " + externalIdBundle + " from " + timeSeries.getEarliestTime() + " to " + timeSeries.getLatestTime());
View Full Code Here

Examples of com.opengamma.master.historicaltimeseries.ManageableHistoricalTimeSeriesInfo

    if (identifierBundle != null) {
      Collection<ManageableHistoricalTimeSeriesInfo> timeSeriesCandidates = search(identifierBundle, identifierValidityDate, dataSource, dataProvider, dataField);
      if (!fieldMappings.isEmpty()) {
        Iterator<ManageableHistoricalTimeSeriesInfo> it = timeSeriesCandidates.iterator();
        while (it.hasNext()) {
          ManageableHistoricalTimeSeriesInfo candidate = it.next();
          HistoricalTimeSeriesFieldAdjustment fieldAdjustment = fieldMappings.get(candidate.getDataSource());
          if (fieldAdjustment == null ||
              ((fieldAdjustment.getUnderlyingDataProvider() != null && !fieldAdjustment.getUnderlyingDataProvider().equals(candidate.getDataProvider()))
              || !fieldAdjustment.getUnderlyingDataField().equals(candidate.getDataField()))) {
            // Incompatible
            it.remove();
          }
        }
      }
      ManageableHistoricalTimeSeriesInfo selectedResult = select(timeSeriesCandidates, resolutionKey);
      if (selectedResult == null) {
        s_logger.debug("Resolver failed to find any time-series for {} using {}/{}", new Object[] {identifierBundle, dataField, resolutionKey });
        return null;
      }
      HistoricalTimeSeriesFieldAdjustment fieldAdjustment = fieldMappings.get(selectedResult.getDataSource());
      HistoricalTimeSeriesAdjuster adjuster = fieldAdjustment != null ? fieldAdjustment.getAdjuster() : null;
      return new HistoricalTimeSeriesResolutionResult(selectedResult, adjuster);
    } else {
      return search(dataSource, dataProvider, dataField);
    }
View Full Code Here

Examples of com.opengamma.master.historicaltimeseries.ManageableHistoricalTimeSeriesInfo

    }
    if (MarketDataRequirementNames.MARKET_VALUE != dataField) {
      s_logger.warn("Redis simulation asked for {} for {}, can only handle market value.", dataField, externalId);
      return null;
    }
    ManageableHistoricalTimeSeriesInfo htsInfo = new ManageableHistoricalTimeSeriesInfo() {
      private static final long serialVersionUID = 1L;

      @Override
      public UniqueId getUniqueId() {
        return uniqueId;
View Full Code Here

Examples of com.opengamma.master.historicaltimeseries.ManageableHistoricalTimeSeriesInfo

        return null;
      }
    }
    resolveResult = _underlying.resolve(identifierBundle, identifierValidityDate, dataSource, dataProvider, dataField, resolutionKey);
    if (resolveResult != null) {
      ManageableHistoricalTimeSeriesInfo info = resolveResult.getHistoricalTimeSeriesInfo();
      for (ExternalIdWithDates id : info.getExternalIdBundle()) {
        if (id.isValidOn(identifierValidityDate)) {
          String key = id.getExternalId().toString() + SEPARATOR +
              dataField + SEPARATOR +
              info.getDataSource() + SEPARATOR +
              info.getDataProvider() + SEPARATOR +
              resolutionKey;
          addResultToCache(key, id, resolveResult);

          key = id.getExternalId().toString() + SEPARATOR +
              dataField + SEPARATOR +
              SEPARATOR +
              info.getDataProvider() + SEPARATOR +
              resolutionKey;
          addResultToCache(key, id, resolveResult);

          key = id.getExternalId().toString() + SEPARATOR +
              dataField + SEPARATOR +
              info.getDataSource() + SEPARATOR +
              SEPARATOR +
              resolutionKey;
          addResultToCache(key, id, resolveResult);

          key = id.getExternalId().toString() + SEPARATOR +
View Full Code Here

Examples of com.opengamma.master.historicaltimeseries.ManageableHistoricalTimeSeriesInfo

   
    try (Timer.Context context = _insertTimer.time()) {
      final long docId = nextId("hts_master_seq");
      final long docOid = (document.getUniqueId() != null ? extractOid(document.getUniqueId()) : docId);
      // the arguments for inserting into the table
      final ManageableHistoricalTimeSeriesInfo info = document.getInfo();
      final DbMapSqlParameterSource docArgs = new DbMapSqlParameterSource()
        .addValue("doc_id", docId)
        .addValue("doc_oid", docOid)
        .addTimestamp("ver_from_instant", document.getVersionFromInstant())
        .addTimestampNullFuture("ver_to_instant", document.getVersionToInstant())
        .addTimestamp("corr_from_instant", document.getCorrectionFromInstant())
        .addTimestampNullFuture("corr_to_instant", document.getCorrectionToInstant())
        .addValue("name_id", getNameTable().ensure(info.getName()))
        .addValue("data_field_id", getDataFieldTable().ensure(info.getDataField()))
        .addValue("data_source_id", getDataSourceTable().ensure(info.getDataSource()))
        .addValue("data_provider_id", getDataProviderTable().ensure(info.getDataProvider()))
        .addValue("observation_time_id", getObservationTimeTable().ensure(info.getObservationTime()));
      // the arguments for inserting into the idkey tables
      final List<DbMapSqlParameterSource> assocList = new ArrayList<DbMapSqlParameterSource>();
      final List<DbMapSqlParameterSource> idKeyList = new ArrayList<DbMapSqlParameterSource>();
      final String sqlSelectIdKey = getElSqlBundle().getSql("SelectIdKey");
      for (ExternalIdWithDates id : info.getExternalIdBundle()) {
        final DbMapSqlParameterSource assocArgs = new DbMapSqlParameterSource()
          .addValue("doc_id", docId)
          .addValue("key_scheme", id.getExternalId().getScheme().getName())
          .addValue("key_value", id.getExternalId().getValue())
          .addValue("valid_from", DbDateUtils.toSqlDateNullFarPast(id.getValidFrom()))
          .addValue("valid_to", DbDateUtils.toSqlDateNullFarFuture(id.getValidTo()));
        assocList.add(assocArgs);
        if (getJdbcTemplate().queryForList(sqlSelectIdKey, assocArgs).isEmpty()) {
          // select avoids creating unecessary id, but id may still not be used
          final long idKeyId = nextId("hts_idkey_seq");
          final DbMapSqlParameterSource idkeyArgs = new DbMapSqlParameterSource()
            .addValue("idkey_id", idKeyId)
            .addValue("key_scheme", id.getExternalId().getScheme().getName())
            .addValue("key_value", id.getExternalId().getValue());
          idKeyList.add(idkeyArgs);
        }
      }

      // insert
      final String sqlDoc = getElSqlBundle().getSql("Insert", docArgs);
      final String sqlIdKey = getElSqlBundle().getSql("InsertIdKey");
      final String sqlDoc2IdKey = getElSqlBundle().getSql("InsertDoc2IdKey");
      getJdbcTemplate().update(sqlDoc, docArgs);
      getJdbcTemplate().batchUpdate(sqlIdKey, idKeyList.toArray(new DbMapSqlParameterSource[idKeyList.size()]));
      getJdbcTemplate().batchUpdate(sqlDoc2IdKey, assocList.toArray(new DbMapSqlParameterSource[assocList.size()]));

      // set the uniqueId
      final UniqueId uniqueId = createUniqueId(docOid, docId);
      info.setUniqueId(uniqueId);
      document.setUniqueId(uniqueId);
      document.getInfo().setTimeSeriesObjectId(uniqueId.getObjectId().withValue(DATA_POINT_PREFIX + uniqueId.getValue()));
      return document;
    }
  }
View Full Code Here

Examples of com.opengamma.master.historicaltimeseries.ManageableHistoricalTimeSeriesInfo

      final String dataSource = rs.getString("DATA_SOURCE");
      final String dataProvider = rs.getString("DATA_PROVIDER");
      final String observationTime = rs.getString("OBSERVATION_TIME");

      UniqueId uniqueId = createUniqueId(docOid, docId);
      _info = new ManageableHistoricalTimeSeriesInfo();
      _info.setUniqueId(uniqueId);
      _info.setName(name);
      _info.setDataField(dataField);
      _info.setDataSource(dataSource);
      _info.setDataProvider(dataProvider);
View Full Code Here

Examples of com.opengamma.master.historicaltimeseries.ManageableHistoricalTimeSeriesInfo

    assertEquals(uniqueId, test.getUniqueId());
    assertEquals(_version1Instant, test.getVersionFromInstant());
    assertEquals(_version2Instant, test.getVersionToInstant());
    assertEquals(_version1Instant, test.getCorrectionFromInstant());
    assertEquals(null, test.getCorrectionToInstant());
    ManageableHistoricalTimeSeriesInfo info = test.getInfo();
    assertNotNull(info);
    assertEquals(uniqueId, info.getUniqueId());
    assertEquals("N201", info.getName());
    assertEquals("DF11", info.getDataField());
    assertEquals("DS21", info.getDataSource());
    assertEquals("DP31", info.getDataProvider());
    assertEquals("OT41", info.getObservationTime());
    ExternalIdBundleWithDates key = info.getExternalIdBundle();
    assertNotNull(key);
    assertEquals(2, key.size());
    assertEquals(true, key.getExternalIds().contains(
        ExternalIdWithDates.of(ExternalId.of("TICKER", "V505"), null, null)));
    assertEquals(true, key.getExternalIds().contains(
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.