Package com.opengamma.master.portfolio

Examples of com.opengamma.master.portfolio.ManageablePortfolio


    final PortfolioMaster portfolioMaster = getToolContext().getPortfolioMaster();
    final PositionMaster positionMaster = getToolContext().getPositionMaster();
    final SecurityMaster securityMaster = getToolContext().getSecurityMaster();

    final ManageablePortfolioNode rootNode = new ManageablePortfolioNode(portfolioName);
    final ManageablePortfolio portfolio = new ManageablePortfolio(portfolioName, rootNode);
    final PortfolioDocument portfolioDoc = new PortfolioDocument();
    portfolioDoc.setPortfolio(portfolio);

    for (final FinancialSecurity security : securities) {
      final SecurityDocument securityToAddDoc = new SecurityDocument();
View Full Code Here


   * Loads the test portfolio into the position master.
   */
  @Override
  protected void doRun() {
    // create shell portfolio
    final ManageablePortfolio portfolio = createPortfolio();
    final ManageablePortfolioNode rootNode = portfolio.getRootNode();
   
    // add each security to the portfolio
    for (SecurityDocument shellDoc : loadAllBondSecurities()) {
      // load the full detail of the security
      final BondSecurity security = loadFullSecurity(shellDoc);
View Full Code Here

   * Subsequent methods then populate the tree.
   *
   * @return the shell portfolio, not null
   */
  protected ManageablePortfolio createPortfolio() {
    ManageablePortfolio portfolio = new ManageablePortfolio(PORTFOLIO_NAME);
    ManageablePortfolioNode rootNode = portfolio.getRootNode();
    rootNode.setName("Root");
    return portfolio;
  }
View Full Code Here

  private ManageablePortfolio createManageablePortfolio(final Portfolio portfolio) {
    if (!_rewriteExistingPositions) {
      populatePositionMapCache(portfolio.getRootNode());
    }
    final ManageablePortfolio manageablePortfolio = new ManageablePortfolio();
    manageablePortfolio.setName(getPortfolioName(portfolio));
    manageablePortfolio.setRootNode(createManageablePortfolioNode(portfolio.getRootNode()));
    manageablePortfolio.setAttributes(portfolio.getAttributes());
    return manageablePortfolio;
  }
View Full Code Here

      final Timestamp versionTo = rs.getTimestamp("VER_TO_INSTANT");
      final Timestamp correctionFrom = rs.getTimestamp("CORR_FROM_INSTANT");
      final Timestamp correctionTo = rs.getTimestamp("CORR_TO_INSTANT");
      final String name = StringUtils.defaultString(rs.getString("PORTFOLIO_NAME"));
      final DocumentVisibility visibility = DocumentVisibility.ofLevel(rs.getShort("VISIBILITY"));
      _portfolio = new ManageablePortfolio(name);
      _portfolio.setUniqueId(createUniqueId(portfolioOid, portfolioId));
      final PortfolioDocument doc = new PortfolioDocument(_portfolio);
      doc.setVersionFromInstant(DbDateUtils.fromSqlTimestamp(versionFrom));
      doc.setVersionToInstant(DbDateUtils.fromSqlTimestampNullFarFuture(versionTo));
      doc.setCorrectionFromInstant(DbDateUtils.fromSqlTimestamp(correctionFrom));
View Full Code Here

    s_logger.debug("Saving portfolio '{}'", portfolio.getName());
    final PortfolioSearchRequest request = new PortfolioSearchRequest();
    request.setName(getPortfolioName(portfolio));
    request.setVisibility(visibility)// Any existing match needs to be at least as visible
    final PortfolioSearchResult result = _portfolios.search(request);
    final ManageablePortfolio manageablePortfolio = createManageablePortfolio(portfolio);
    PortfolioDocument document;
    if (updateMatchingName) {
      document = result.getFirstDocument();
      // TODO why did this assume document will never be null? is that valid or have I broken something?
      if (document != null) {
        final ManageablePortfolio resultPortfolio = document.getPortfolio();
        if (nodesEqual(manageablePortfolio.getRootNode(), resultPortfolio.getRootNode())) {
          s_logger.debug("Found existing match at {}", document.getUniqueId());
          return document.getUniqueId();
        }
      }
    } else {
      document = null;
      for (PortfolioDocument resultDocument : result.getDocuments()) {
        final ManageablePortfolio resultPortfolio = resultDocument.getPortfolio();
        if (manageablePortfolio.getName().equals(resultPortfolio.getName()) && nodesEqual(manageablePortfolio.getRootNode(), resultPortfolio.getRootNode())) {
          s_logger.debug("Found existing match at {}", resultDocument.getUniqueId());
          return resultDocument.getUniqueId();
        }
      }
    }
View Full Code Here

    final PortfolioMaster portfolioMaster = getToolContext().getPortfolioMaster();
    final PositionMaster positionMaster = getToolContext().getPositionMaster();
    final SecurityMaster securityMaster = getToolContext().getSecurityMaster();

    final ManageablePortfolioNode rootNode = new ManageablePortfolioNode(portfolioName);
    final ManageablePortfolio portfolio = new ManageablePortfolio(portfolioName, rootNode);
    final PortfolioDocument portfolioDoc = new PortfolioDocument();
    portfolioDoc.setPortfolio(portfolio);

    final Iterator<Collection<FinancialSecurity>> iter1 = subPortfolios.iterator();
    final Iterator<String> iter2 = names.iterator();
    final Random random = new Random(2349);
    while (iter1.hasNext()) {
      final Collection<FinancialSecurity> securities = iter1.next();
      final String name = iter2.next();
      final ManageablePortfolioNode subNode = new ManageablePortfolioNode(name);
      final ManageablePortfolio subPortfolio = new ManageablePortfolio(name, subNode);
      final PortfolioDocument subPortfolioDoc = new PortfolioDocument();
      subPortfolioDoc.setPortfolio(subPortfolio);
      for (final FinancialSecurity security : securities) {
        final SecurityDocument securityToAddDoc = new SecurityDocument();
        securityToAddDoc.setSecurity(security);
View Full Code Here

    _builder = new OtcTradeBuilder(_positionMaster,
                                   _portfolioMaster,
                                   _securityMaster,
                                   BlotterUtils.getMetaBeans(),
                                   BlotterUtils.getStringConvert());
    ManageablePortfolio portfolio = new ManageablePortfolio();
    ManageablePortfolioNode root = new ManageablePortfolioNode();
    ManageablePortfolioNode node = new ManageablePortfolioNode();
    root.addChildNode(node);
    portfolio.setRootNode(root);
    _savedPortfolio = _portfolioMaster.add(new PortfolioDocument(portfolio)).getPortfolio();
    _nodeId = _savedPortfolio.getRootNode().getChildNodes().get(0).getUniqueId();
  }
View Full Code Here

  //-------------------------------------------------------------------------
  protected ManageablePortfolio generatePortfolio(final String portfolioName) {
    final ReferenceDataProvider referenceDataProvider = getToolContext().getBloombergReferenceDataProvider();

    final ManageablePortfolio portfolio = new ManageablePortfolio(portfolioName);

    //Is this a hack?
    final ManageablePortfolioNode rootNode = portfolio.getRootNode();
    portfolio.setRootNode(rootNode);

    //    String indexTickerSuffix = " Index";

    final Set<String> memberEquities = new HashSet<String>();
View Full Code Here

    s_logger.info("Using portfolio \"{}\"", PORTFOLIO_NAME);
    s_logger.info("num index members: " + _numMembers);
    s_logger.info("Option Depth: " + _numOptions);
    s_logger.info("num contracts: {}", _numContracts.toString());
    final ManageablePortfolio portfolio = generatePortfolio(PORTFOLIO_NAME);
    storePortfolio(portfolio);

    s_logger.info(TOOL_NAME + " is finished.");
  }
View Full Code Here

TOP

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

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.