Package com.opengamma.master.marketdatasnapshot

Examples of com.opengamma.master.marketdatasnapshot.MarketDataSnapshotSearchResult


    ArgumentChecker.notNull(request.getPagingRequest(), "request.pagingRequest");
    ArgumentChecker.notNull(request.getVersionCorrection(), "request.versionCorrection");
    s_logger.debug("search {}", request);
   
    final VersionCorrection vc = request.getVersionCorrection().withLatestFixed(now());
    final MarketDataSnapshotSearchResult result = new MarketDataSnapshotSearchResult(vc);
   
    final List<ObjectId> snapshotIds = request.getSnapshotIds();
    if (snapshotIds != null && snapshotIds.size() == 0) {
      result.setPaging(Paging.of(request.getPagingRequest(), 0));
      return result;
    }
   
    final DbMapSqlParameterSource args = new DbMapSqlParameterSource();
    args.addTimestamp("version_as_of_instant", vc.getVersionAsOf());
View Full Code Here


  }

  private static MarketDataSnapshotListResource createResource(MarketDataSnapshotDocument... docs) {
    MarketDataSnapshotMaster snapshotMaster = mock(MarketDataSnapshotMaster.class);
    List<MarketDataSnapshotDocument> documents = Arrays.asList(docs);
    MarketDataSnapshotSearchResult result = new MarketDataSnapshotSearchResult(documents);
    when(snapshotMaster.search(any(MarketDataSnapshotSearchRequest.class))).thenReturn(result);
    return new MarketDataSnapshotListResource(snapshotMaster);
  }
View Full Code Here

    // Search by name with data
    final MarketDataSnapshotSearchRequest request1 = new MarketDataSnapshotSearchRequest();
    request1.setIncludeData(true);
    request1.setName(doc1.getName());
    final MarketDataSnapshotSearchResult result1 = _snpMaster.search(request1);
    assertTrue(result1.getDocuments().size() > 0);

    // Search by name without data
    final MarketDataSnapshotSearchRequest request2 = new MarketDataSnapshotSearchRequest();
    request2.setIncludeData(false);
    request2.setName(doc1.getName());
    final MarketDataSnapshotSearchResult result2 = _snpMaster.search(request2);
    assertTrue(result2.getDocuments().size() > 0);
    assertEquals(result1.getDocuments().size(), result2.getDocuments().size());

    // Search by ID
    final MarketDataSnapshotSearchRequest request3 = new MarketDataSnapshotSearchRequest();
    request3.setSnapshotIds(ImmutableSet.of(doc1.getUniqueId().getObjectId()));
    final MarketDataSnapshotSearchResult result3 = _snpMaster.search(request3);
    assertEquals(1, result3.getDocuments().size());
    assertEquals(doc1.getUniqueId(), result3.getFirstDocument().getUniqueId());
  }
View Full Code Here

    final SecurityMaster securityMaster = getToolContext().getSecurityMaster();

    String snapshotName = "Sameday spread";
    MarketDataSnapshotSearchRequest marketDataSnapshotSearchRequest = new MarketDataSnapshotSearchRequest();
    marketDataSnapshotSearchRequest.setName(snapshotName);
    MarketDataSnapshotSearchResult marketDataSnapshotSearchResult = getToolContext().getMarketDataSnapshotMaster().search(marketDataSnapshotSearchRequest);
    ManageableMarketDataSnapshot snapshot = marketDataSnapshotSearchResult.getFirstSnapshot();

    PortfolioSearchRequest portfolioSearchRequest = new PortfolioSearchRequest();
    portfolioSearchRequest.setName("CDSOpts");
    //portfolioSearchRequest.setName("Standard CDS Portfolio");
    List<ManageablePortfolio> portfolios = getToolContext().getPortfolioMaster().search(portfolioSearchRequest).getPortfolios();
View Full Code Here

      if (snapshotMaster == null) {
        throw new OpenGammaRuntimeException("MarketDataSnapshotMaster is missing from given Toolcontext");
      }
      MarketDataSnapshotSearchRequest request = new MarketDataSnapshotSearchRequest();
      request.setName(snapshotOption);
      MarketDataSnapshotSearchResult searchResult = snapshotMaster.search(request);
      if (searchResult.getDocuments().isEmpty()) {
        throw new OpenGammaRuntimeException("No matching snapshot for given name [" + marketDataOption + "]");
      }
      return new UserMarketDataSpecification(searchResult.getFirstDocument().getUniqueId());
    }
    String historicalOption = trimToNull(commandLine.getOptionValue(HISTORICAL_MARKET_DATA_OPT));
    if (historicalOption != null) {
      Matcher matcher = USER_OR_HISTORICAL_PATTERN.matcher(historicalOption);
      if (matcher.matches()) {
View Full Code Here

   * @return the list of all available snapshot ids and names or an empty list if no snapshots found
   */
  public List<String> allSnapshots() {
    MarketDataSnapshotSearchRequest searchRequest = new MarketDataSnapshotSearchRequest();
    searchRequest.setIncludeData(false);
    MarketDataSnapshotSearchResult searchResult = _snapshotMaster.search(searchRequest);
    List<String> results = new ArrayList<>();
    for (MarketDataSnapshotDocument doc : searchResult.getDocuments()) {
      results.add(getSnapshotNameId(doc));
    }
    return results;
  }
View Full Code Here

   */
  public List<String> snapshotByGlob(String query) {
    MarketDataSnapshotSearchRequest searchRequest = new MarketDataSnapshotSearchRequest();
    searchRequest.setName(query);
    searchRequest.setIncludeData(false);
    MarketDataSnapshotSearchResult searchResult = _snapshotMaster.search(searchRequest);
    List<String> results = new ArrayList<>();
    for (MarketDataSnapshotDocument doc : searchResult.getDocuments()) {
      results.add(getSnapshotNameId(doc));
    }
    return results;
  }
View Full Code Here

   */
  public UniqueId latestSnapshotByName(String name) {
    MarketDataSnapshotSearchRequest searchRequest = new MarketDataSnapshotSearchRequest();
    searchRequest.setName(name);
    searchRequest.setIncludeData(false);
    MarketDataSnapshotSearchResult searchResult = _snapshotMaster.search(searchRequest);
    if (searchResult.getDocuments().size() > 1) {
      throw new OpenGammaRuntimeException("More than one snapshot matches supplied name");
    }
    if (searchResult.getDocuments().size() == 0) {
      return null;
    }
    return searchResult.getFirstDocument().getUniqueId();  
  }
View Full Code Here

   */
  public UniqueId latestSnapshotByNameAndDate(String name, ZonedDateTime dateTime) {
    MarketDataSnapshotSearchRequest searchRequest = new MarketDataSnapshotSearchRequest();
    searchRequest.setName(name);
    searchRequest.setIncludeData(false);
    MarketDataSnapshotSearchResult searchResult = _snapshotMaster.search(searchRequest);
    searchRequest.setVersionCorrection(VersionCorrection.ofVersionAsOf(dateTime.toInstant()));
    if (searchResult.getDocuments().size() > 1) {
      throw new OpenGammaRuntimeException("More than one snapshot matches supplied name");
    }
    if (searchResult.getDocuments().size() == 0) {
      return null;
    }
    return searchResult.getFirstDocument().getUniqueId();  
  }
View Full Code Here

   */
  public List<VersionInfo> snapshotVersionsByName(String name) {
    MarketDataSnapshotSearchRequest searchRequest = new MarketDataSnapshotSearchRequest();
    searchRequest.setName(name);
    searchRequest.setIncludeData(false);
    MarketDataSnapshotSearchResult searchResult = _snapshotMaster.search(searchRequest);
    if (searchResult.getDocuments().size() > 1) {
      s_logger.warn("More than one snapshot matches supplied name, using first");
    }
    if (searchResult.getDocuments().size() == 0) {
      return Collections.emptyList();
    }
    ObjectId objectId = searchResult.getFirstDocument().getObjectId();
    MarketDataSnapshotHistoryResult historyResult = _snapshotMaster.history(new MarketDataSnapshotHistoryRequest(objectId));
    List<VersionInfo> results = new ArrayList<>();
    for (MarketDataSnapshotDocument doc : historyResult.getDocuments()) {
      results.add(new VersionInfo(doc.getVersionFromInstant(), doc.getCorrectionFromInstant(), doc.getVersionToInstant(), doc.getCorrectionToInstant(), doc.getUniqueId()));
    }
View Full Code Here

TOP

Related Classes of com.opengamma.master.marketdatasnapshot.MarketDataSnapshotSearchResult

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.