Package com.opengamma.master.historicaltimeseries

Examples of com.opengamma.master.historicaltimeseries.HistoricalTimeSeriesInfoSearchResult


    for (HistoricalTimeSeriesInfoDocument doc : _store.values()) {
      if (request.matches(doc)) {
        list.add(doc);
      }
    }
    HistoricalTimeSeriesInfoSearchResult result = new HistoricalTimeSeriesInfoSearchResult();
    result.setPaging(Paging.of(request.getPagingRequest(), list));
    result.getDocuments().addAll(request.getPagingRequest().select(list));
    return result;
  }
View Full Code Here


    final HistoricalTimeSeriesInfoSearchRequest searchRequest = new HistoricalTimeSeriesInfoSearchRequest(identifierBundle);
    searchRequest.setValidityDate(identifierValidityDate);
    searchRequest.setDataSource(dataSource);
    searchRequest.setDataProvider(dataProvider);
    searchRequest.setDataField(dataField);
    final HistoricalTimeSeriesInfoSearchResult searchResult = _master.search(searchRequest);
    return searchResult.getInfoList();
  }
View Full Code Here

        final HistoricalTimeSeriesInfoSearchRequest searchRequest = new HistoricalTimeSeriesInfoSearchRequest();
        searchRequest.addExternalId(centreValue.getKey().getFirst());
        searchRequest.setDataField(centreValue.getKey().getSecond());
        searchRequest.setDataProvider(SimulatedHistoricalData.OG_DATA_PROVIDER);
        searchRequest.setDataSource(SimulatedHistoricalData.OG_DATA_SOURCE);
        final HistoricalTimeSeriesInfoSearchResult searchResult = htsMaster.search(searchRequest);
        if (searchResult.getDocuments().isEmpty()) {
          s_logger.warn("No time series for {}/{}", centreValue.getKey().getFirst(), centreValue.getKey().getSecond());
        } else {
          for (HistoricalTimeSeriesInfoDocument infoDoc : searchResult.getDocuments()) {
            s_logger.debug("Updating {}", infoDoc.getUniqueId());
            final ManageableHistoricalTimeSeries hts = htsMaster.getTimeSeries(infoDoc.getUniqueId(), filter);
            final LocalDateDoubleTimeSeries ldts = hts.getTimeSeries();
            LocalDate pointDate = ldts.getLatestTime();
            if (pointDate.isBefore(now)) {
View Full Code Here

      searchRequest.setDataProvider(BloombergConstants.DEFAULT_DATA_PROVIDER);
    } else {
      searchRequest.setDataProvider(dataProvider);
    }
    searchRequest.setDataSource(BLOOMBERG_DATA_SOURCE_NAME);
    HistoricalTimeSeriesInfoSearchResult searchResult = _htsMaster.search(searchRequest);
   
    Set<ExternalId> missing = new HashSet<ExternalId>(externalIds);
    for (HistoricalTimeSeriesInfoDocument doc : searchResult.getDocuments()) {
      Set<ExternalId> intersection = Sets.intersection(doc.getInfo().getExternalIdBundle().toBundle().getExternalIds(), externalIds).immutableCopy();
      if (intersection.size() == 1) {
        ExternalId identifier = intersection.iterator().next();
        missing.remove(identifier);
        result.put(identifier, doc.getUniqueId());
View Full Code Here

        request.setDataField(info.getDataField());
        request.setDataSource(info.getDataSource());
        request.setDataProvider(info.getDataProvider());
        request.setObservationTime(info.getObservationTime());
        request.setExternalIdSearch(new ExternalIdSearch(info.getExternalIdBundle().toBundle(), ExternalIdSearchType.EXACT));
        HistoricalTimeSeriesInfoSearchResult searchResult = _htsMaster.search(request);
        if (searchResult.getDocuments().size() == 0) {
          // add new
          HistoricalTimeSeriesInfoDocument doc = _htsMaster.add(new HistoricalTimeSeriesInfoDocument(info));
          UniqueId uniqueId = _htsMaster.updateTimeSeriesDataPoints(doc.getInfo().getTimeSeriesObjectId(), timeSeries);
          result.put(bundleToIdentifier.get(bundleWithDates), uniqueId);
        } else {
          // update existing
          HistoricalTimeSeriesInfoDocument doc = searchResult.getDocuments().get(0);
          HistoricalTimeSeries existingSeries = _htsMaster.getTimeSeries(doc.getInfo().getTimeSeriesObjectId(), VersionCorrection.LATEST, HistoricalTimeSeriesGetFilter.ofLatestPoint());
          if (existingSeries.getTimeSeries().size() > 0) {
            LocalDate latestTime = existingSeries.getTimeSeries().getLatestTime();
            timeSeries = timeSeries.subSeries(latestTime, false, timeSeries.getLatestTime(), true);
          }
View Full Code Here

    List<FactorExposure> results = new ArrayList<FactorExposure>();
    for (FactorExposureData exposure : factorExposureDataList) {
      HistoricalTimeSeriesInfoSearchRequest exposureSearchRequest = new HistoricalTimeSeriesInfoSearchRequest();
      exposureSearchRequest.addExternalId(exposure.getExposureExternalId());
      exposureSearchRequest.setDataField("EXPOSURE");
      HistoricalTimeSeriesInfoSearchResult exposureSearchResult = data().getHistoricalTimeSeriesMaster().search(exposureSearchRequest);
      HistoricalTimeSeries exposureHTS = null;
      if (exposureSearchResult.getFirstInfo() != null) {
        exposureHTS = data().getHistoricalTimeSeriesMaster().getTimeSeries(exposureSearchResult.getFirstInfo().getTimeSeriesObjectId(), VersionCorrection.LATEST);
      }

      HistoricalTimeSeriesInfoSearchRequest convexitySearchRequest = new HistoricalTimeSeriesInfoSearchRequest();
      convexitySearchRequest.addExternalId(exposure.getExposureExternalId());
      convexitySearchRequest.setDataField("CONVEXITY");
      HistoricalTimeSeriesInfoSearchResult convexitySearchResult = data().getHistoricalTimeSeriesMaster().search(convexitySearchRequest);
      HistoricalTimeSeries convexityHTS = null;
      if (convexitySearchResult.getFirstInfo() != null) {
        convexityHTS = data().getHistoricalTimeSeriesMaster().getTimeSeries(convexitySearchResult.getFirstInfo().getTimeSeriesObjectId(), VersionCorrection.LATEST);
      }

      HistoricalTimeSeriesInfoSearchRequest priceSearchRequest = new HistoricalTimeSeriesInfoSearchRequest();
      priceSearchRequest.addExternalId(exposure.getExposureExternalId());
      priceSearchRequest.setDataField("PX_LAST");
      HistoricalTimeSeriesInfoSearchResult priceSearchResult = data().getHistoricalTimeSeriesMaster().search(priceSearchRequest);
      HistoricalTimeSeries priceHTS = null;
      if (priceSearchResult.getFirstInfo() != null) {
        priceHTS = data().getHistoricalTimeSeriesMaster().getTimeSeries(priceSearchResult.getFirstInfo().getTimeSeriesObjectId(), VersionCorrection.LATEST);
      }

      results.add(new FactorExposure(exposure.getFactorType().getFactorType(),
        exposure.getFactorName(),
        exposure.getNode(),
View Full Code Here

    }
    out.put("searchRequest", searchRequest);
   
    if (data().getUriInfo().getQueryParameters().size() > 0) {
      ExternalIdWithDatesDisplayComparator comparator = ExternalIdWithDatesDisplayComparatorUtils.getComparator(data().getConfigSource(), ExternalIdDisplayComparatorUtils.DEFAULT_CONFIG_NAME);
      HistoricalTimeSeriesInfoSearchResult searchResult = data().getHistoricalTimeSeriesMaster().search(searchRequest);
      for (HistoricalTimeSeriesInfoDocument doc : searchResult.getDocuments()) {
        // replace ids with one's sorted the way we want.
        ExternalIdBundleWithDates withCustomIdOrdering = doc.getInfo().getExternalIdBundle().withCustomIdOrdering(comparator);
        doc.getInfo().setExternalIdBundle(withCustomIdOrdering);
      }
      out.put("searchResult", searchResult);
      out.put("paging", new WebPaging(searchResult.getPaging(), data().getUriInfo()));
    }
    return out;
  }
View Full Code Here

   
    // Get the last price HTS for the security
    ObjectId tsObjectId = null;
    HistoricalTimeSeriesInfoSearchRequest searchRequest =
        new HistoricalTimeSeriesInfoSearchRequest(security.getExternalIdBundle());
    HistoricalTimeSeriesInfoSearchResult searchResult = data().getHistoricalTimeSeriesMaster().search(searchRequest);
    if (searchResult.getFirstInfo() != null) {
      tsObjectId = searchResult.getFirstInfo().getUniqueId().getObjectId();
    }

    out.put("securityAttributes", security.getAttributes());
    out.put("securityDoc", securityDoc);
    out.put("security", security);
View Full Code Here

  private Collection<ManageableHistoricalTimeSeriesInfo> getRelatedTimeSeries() {
    HistoricalTimeSeriesInfoSearchRequest searchRequest =
        new HistoricalTimeSeriesInfoSearchRequest(data().getInfo().getInfo().getExternalIdBundle().toBundle());
    searchRequest.setPagingRequest(PagingRequest.FIRST_PAGE);
    HistoricalTimeSeriesInfoSearchResult searchResult = data().getHistoricalTimeSeriesMaster().search(searchRequest);   
    Collection<ManageableHistoricalTimeSeriesInfo> result = searchResult.getInfoList();
    result.remove(data().getInfo().getInfo()); // remove the original time series itself from its related list
    return result;
  }
View Full Code Here

    // Create the document search cache and register a historicalTimeSeries master searcher
    _documentSearchCache = new EHCachingSearchCache(name + "HistoricalTimeSeries", cacheManager, new EHCachingSearchCache.Searcher() {
      @Override
      public ObjectsPair<Integer, List<UniqueId>> search(Bean request, PagingRequest pagingRequest) {
        // Fetch search results from underlying master
        HistoricalTimeSeriesInfoSearchResult result = ((HistoricalTimeSeriesMaster) getUnderlying()).search((HistoricalTimeSeriesInfoSearchRequest)
            EHCachingSearchCache.withPagingRequest(request, pagingRequest));

        // Cache the result documents
        EHCachingSearchCache.cacheDocuments(result.getDocuments(), getUidToDocumentCache());

        // Return the list of result UniqueIds
        return new ObjectsPair<>(result.getPaging().getTotalItems(),
                                 EHCachingSearchCache.extractUniqueIds(result.getDocuments()));
      }
    });

    // Create the history search cache and register a historicalTimeSeries master searcher
    _historySearchCache = new EHCachingSearchCache(name + "HistoricalTimeSeriesHistory", cacheManager, new EHCachingSearchCache.Searcher() {
      @Override
      public ObjectsPair<Integer, List<UniqueId>> search(Bean request, PagingRequest pagingRequest) {
        // Fetch search results from underlying master
        HistoricalTimeSeriesInfoHistoryResult result = ((HistoricalTimeSeriesMaster) getUnderlying()).history((HistoricalTimeSeriesInfoHistoryRequest)
            EHCachingSearchCache.withPagingRequest(request, pagingRequest));

        // Cache the result documents
        EHCachingSearchCache.cacheDocuments(result.getDocuments(), getUidToDocumentCache());

        // Return the list of result UniqueIds
        return new ObjectsPair<>(result.getPaging().getTotalItems(),
                                 EHCachingSearchCache.extractUniqueIds(result.getDocuments()));
      }
    });

    // Prime document search cache
    HistoricalTimeSeriesInfoSearchRequest defaultSearch = new HistoricalTimeSeriesInfoSearchRequest();
View Full Code Here

TOP

Related Classes of com.opengamma.master.historicaltimeseries.HistoricalTimeSeriesInfoSearchResult

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.