Package com.opengamma.master.portfolio

Examples of com.opengamma.master.portfolio.PortfolioSearchRequest


  }

  //-------------------------------------------------------------------------
  @Test
  public void test_search_noPositions() {
    PortfolioSearchRequest request = new PortfolioSearchRequest();
    request.setIncludePositions(false);
    PortfolioSearchResult test = _prtMaster.search(request);
   
    assertEquals(_visiblePortfolios, test.getDocuments().size());
    assertNoPositions();
    assert101(test.getDocuments().get(0), 999);
View Full Code Here


   
    PortfolioDocument b = new PortfolioDocument();
    b.setPortfolio( new ManageablePortfolio("Name"));
    _prtMaster.add(b);
   
    PortfolioSearchResult search = _prtMaster.search(new PortfolioSearchRequest());
    assertEquals(2, search.getPortfolios().size());
  }
View Full Code Here

        ManageablePortfolioNode child = new ManageablePortfolioNode("X");
        child.addChildNode(new ManageablePortfolioNode("Y"));
        a.getPortfolio().getRootNode().addChildNode(child);
        _prtMaster.update(a);
       
        PortfolioSearchRequest request = new PortfolioSearchRequest();
        request.setName(portfolioName);
        PortfolioSearchResult search = _prtMaster.search(request);
        assertEquals(2 * (i+1), search.getPortfolios().size());
      }
     
      PortfolioSearchRequest request = new PortfolioSearchRequest();
      request.setName(portfolioName);
      PortfolioSearchResult search = _prtMaster.search(request);
      assertEquals(2 * (i+1), search.getPortfolios().size());
    }
  }
View Full Code Here

    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();
    for (ManageablePortfolio portfolio : portfolios) {

      List<ObjectId> positionIds = portfolio.getRootNode().getPositionIds();
View Full Code Here

  }

  protected void createPortfolio(String portfolioName) {

    // Check to see whether the portfolio already exists
    PortfolioSearchRequest portSearchRequest = new PortfolioSearchRequest();
    portSearchRequest.setName(portfolioName);
    PortfolioSearchResult portSearchResult = _portfolioMaster.search(portSearchRequest);

    _portfolioDocument = portSearchResult.getFirstDocument();

    // If it doesn't, create it (add)
View Full Code Here

    }
  
  }

  private UniqueId findPortfolioId(final String portfolioName) {
    final PortfolioSearchRequest searchRequest = new PortfolioSearchRequest();
    searchRequest.setName(portfolioName);
    final PortfolioSearchResult searchResult = getToolContext().getPortfolioMaster().search(searchRequest);
    UniqueId portfolioId = null;
    if (searchResult.getFirstPortfolio() != null) {
      portfolioId = searchResult.getFirstPortfolio().getUniqueId().toLatest();
    }
View Full Code Here

    return result;
  }

  private Set<ObjectId> getValidPositions() {
    final Set<ObjectId> result = Sets.newHashSet();
    PortfolioSearchRequest searchRequest = new PortfolioSearchRequest();
    for (PortfolioDocument portfolioDocument : PortfolioSearchIterator.iterable(_portfolioMaster, searchRequest)) {
      accumulatePositionIdentifiers(portfolioDocument.getPortfolio().getRootNode(), result);
    }
    return result;
  }
View Full Code Here

    System.exit(success ? 0 : 1);
  }

  @Override
  protected void doRun() {
    PortfolioSearchRequest portfolioSearchRequest = new PortfolioSearchRequest();
    portfolioSearchRequest.setName(getCommandLine().getOptionValue(ORIGINAL_PORTFOLIO_NAME));
    PortfolioSearchResult portfolioSearchResult = getToolContext().getPortfolioMaster().search(portfolioSearchRequest);

    if (portfolioSearchResult.getDocuments().size() == 0) {
      throw new OpenGammaRuntimeException("No matching portfolio could be found, will not proceed.");
    } else if (portfolioSearchResult.getDocuments().size() > 1) {
      throw new OpenGammaRuntimeException("More than one portfolio matches, will not proceed.");
    } else {
      PortfolioDocument portfolioDocument = portfolioSearchResult.getFirstDocument();
      PortfolioSearchRequest portfolioSearchRequest1 = new PortfolioSearchRequest();
      portfolioSearchRequest1.setName(getCommandLine().getOptionValue(NEW_PORTFOLIO_NAME));
      PortfolioSearchResult portfolioSearchResult1 = getToolContext().getPortfolioMaster().search(portfolioSearchRequest1);
      if (portfolioSearchResult1.getDocuments().size() != 0) {
        throw new OpenGammaRuntimeException("A portfolio with the specified new name already exists, will not proceed.");
      }
      if (getCommandLine().hasOption(COPY_OPT)) {
View Full Code Here

  }

  //-------------------------------------------------------------------------
  @Override
  protected void doRun() {   
    PortfolioSearchRequest portfolioSearchRequest = new PortfolioSearchRequest();
   
    if (getCommandLine().hasOption(PORTFOLIO_NAMES_OPT)) {
      portfolioSearchRequest.setName(
          getCommandLine().getOptionValue(PORTFOLIO_NAMES_OPT));
    }
   
    if (getCommandLine().hasOption(PORTFOLIO_IDS_OPT)) {
      List<ObjectId> ids = new ArrayList<ObjectId>();
      for (String s : getCommandLine().getOptionValues(PORTFOLIO_IDS_OPT)) {
        ids.add(ObjectId.parse(s));
      }
      portfolioSearchRequest.setPortfolioObjectIds(ids);
    }

    PortfolioSearchResult portSearchResult = getToolContext().getPortfolioMaster().search(portfolioSearchRequest);
     
    for (PortfolioDocument portfolioDocument : portSearchResult.getDocuments()) {
View Full Code Here

    }
  }
       
  private PortfolioDocument openPortfolio(String portfolioName) {
   
    PortfolioSearchRequest portSearchRequest = new PortfolioSearchRequest();
    portSearchRequest.setName(portfolioName);
    PortfolioSearchResult portSearchResult = _portfolioMaster.search(portSearchRequest);
    PortfolioDocument portfolioDoc = portSearchResult.getFirstDocument();
   
    return portfolioDoc;
  }
View Full Code Here

TOP

Related Classes of com.opengamma.master.portfolio.PortfolioSearchRequest

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.