Package com.opengamma.master.portfolio

Examples of com.opengamma.master.portfolio.ManageablePortfolio$Meta


    @Override
    public void run() {  
     
      PortfolioDocument portfolioDocument = getPortfolioMaster().get(_portfolioId, VersionCorrection.LATEST);
      s_logger.debug("Updating portfolio {} with {}", portfolioDocument.getUniqueId(), _trade);
      ManageablePortfolio portfolio = portfolioDocument.getPortfolio();
      ManageablePortfolioNode root = portfolio.getRootNode();

      ManageablePosition position = new ManageablePosition();
      position.getSecurityLink().setExternalId(_trade.getSecurityLink().getExternalId());
      position.setQuantity(_trade.getQuantity());
      String providerIdStr = _trade.getAttributes().get(getProviderIdName());
View Full Code Here


  private UniqueId lookupPortfolioByName(String name) {
    PortfolioSearchRequest searchRequest = new PortfolioSearchRequest();
    searchRequest.setName(name);
    PortfolioSearchResult searchResult = _portfolioMaster.search(searchRequest);
    try {
      ManageablePortfolio singlePortfolio = searchResult.getSinglePortfolio();
      if (_verbose) {
        s_logger.info("Found portfolio called " + name + " mapping in it's id: " + singlePortfolio.getUniqueId());
      }
      return singlePortfolio.getUniqueId();
    } catch (IllegalStateException ise) {
      s_logger.warn("Found multiple portfolios called " + name + " so skipping");
      return null;
    } catch (OpenGammaRuntimeException ogre) {
      if (searchResult.getDocuments().size() > 1) {
View Full Code Here

  @Override
  protected void doRun() {
    final SecurityMaster securities = getToolContext().getSecurityMaster();
    final PositionMaster positions = getToolContext().getPositionMaster();
    final PortfolioMaster portfolios = getToolContext().getPortfolioMaster();
    final ManageablePortfolio portfolio = new ManageablePortfolio("Tutorial 1");
    final ManageablePortfolioNode root = portfolio.getRootNode();
    final Random rnd = new Random();
    root.setName("Root");
    for (final Tutorial1Security security : loadSecurities()) {
      securities.add(new SecurityDocument(security.toRawSecurity()));
      final ManageablePosition position = new ManageablePosition(new BigDecimal(100 + rnd.nextInt(900)), security.getExternalIdBundle());
View Full Code Here

  protected void doRun() {
    // load all equity securities
    final Collection<EquitySecurity> securities = createAndPersistEquitySecurities();

    // create shell portfolio
    final ManageablePortfolio portfolio = createEmptyPortfolio();
    final ManageablePortfolioNode rootNode = portfolio.getRootNode();

    // add each security to the portfolio
    for (EquitySecurity security : securities) {

      GICSCode gics = security.getGicsCode();
View Full Code Here

   * This creates the portfolio and the root of the tree structure that holds the positions. Subsequent methods then populate the tree.
   *
   * @return the emoty portfolio, not null
   */
  protected ManageablePortfolio createEmptyPortfolio() {
    ManageablePortfolio portfolio = new ManageablePortfolio(PORTFOLIO_NAME);
    ManageablePortfolioNode rootNode = portfolio.getRootNode();
    rootNode.setName("Root");
    return portfolio;
  }
View Full Code Here

  }

  private void persistToPortfolio() {
    PortfolioMaster portfolioMaster = getToolContext().getPortfolioMaster();
    ManageablePortfolioNode rootNode = new ManageablePortfolioNode(PORTFOLIO_NAME);
    ManageablePortfolio portfolio = new ManageablePortfolio(PORTFOLIO_NAME, rootNode);
    PortfolioDocument portfolioDoc = new PortfolioDocument();
    portfolioDoc.setPortfolio(portfolio);
    addPortfolioNode(rootNode, getIborSwaps(), "Ibor swaps", BigDecimal.ONE);
    addPortfolioNode(rootNode, getCMSwaps(), "CM swaps", BigDecimal.ONE);
    addPortfolioNode(rootNode, getSimpleFX(), "FX forward", BigDecimal.ONE);
View Full Code Here

   
    final ManageablePosition position = makePositionAndTrade(security);
    final PositionDocument positionDoc = new PositionDocument(position);
    posMaster.add(positionDoc);
   
    ManageablePortfolio portfolio = new ManageablePortfolio(portfolioName);
    ManageablePortfolioNode rootNode = portfolio.getRootNode();
    rootNode.setName("Root");
    rootNode.addPosition(position.getUniqueId());
   
    PortfolioDocument portfolioDoc = new PortfolioDocument(portfolio);
    portMaster.add(portfolioDoc);
View Full Code Here

    // this slightly awkward approach is due to the portfolio master API. you can look up a node directly but in order
    // to save it you have to save the whole portfolio. this means you need to look up the node to find the portfolio
    // ID, look up the portfolio, find the node in the portfolio, modify that copy of the node and save the portfolio
    // TODO can use a portfolio search request and only hit the master once
    ManageablePortfolioNode node = _portfolioMaster.getNode(nodeId);
    ManageablePortfolio portfolio = _portfolioMaster.get(node.getPortfolioId()).getPortfolio();
    ManageablePortfolioNode portfolioNode = findNode(portfolio, nodeId);
    ManageablePosition position = findPosition(portfolioNode, security);
    if (position == null) {
      // no position in this security on the node, create a new position just for this trade
      ManageablePosition newPosition = new ManageablePosition(trade.getQuantity(), security.getExternalIdBundle());
View Full Code Here

    URI uri = createPortfolio(name);
    return Response.seeOther(uri).build();
  }

  private URI createPortfolio(String name) {
    ManageablePortfolio portfolio = new ManageablePortfolio(name);
    PortfolioDocument doc = new PortfolioDocument(portfolio);
    PortfolioDocument added = data().getPortfolioMaster().add(doc);
    return data().getUriInfo().getAbsolutePathBuilder().path(added.getUniqueId().toLatest().toString()).build();
  }
View Full Code Here

    ManageableTrade savedTrade = savedPosition.getTrades().get(0);

    PortfolioSearchRequest searchRequest = new PortfolioSearchRequest();
    searchRequest.addNodeObjectId(nodeId.getObjectId());
    PortfolioSearchResult searchResult = getPortfolioMaster().search(searchRequest);
    ManageablePortfolio portfolio = searchResult.getSinglePortfolio();
    ManageablePortfolioNode node = findNode(portfolio, nodeId);
    node.addPosition(savedPosition.getUniqueId());
    getPortfolioMaster().update(new PortfolioDocument(portfolio));
    return savedTrade.getUniqueId();
  }
View Full Code Here

TOP

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

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.