Package com.opengamma.core.position.impl

Examples of com.opengamma.core.position.impl.SimplePortfolioNode


    return _rightName;
  }

  private Portfolio createPortfolio(final String name, final Collection<Position> positions) {
    final SimplePortfolio portfolio = new SimplePortfolio(name);
    final SimplePortfolioNode rootNode = new SimplePortfolioNode(name);
    rootNode.addPositions(positions);
    portfolio.setRootNode(rootNode);
    return portfolio;
  }
View Full Code Here


    return _size;
  }

  @Override
  public PortfolioNode createPortfolioNode() {
    final SimplePortfolioNode node = new SimplePortfolioNode(getNameGenerator().createName());
    for (int i = 0; i < getSize(); i++) {
      Position position = getPositionGenerator().createPosition();
      // Note: the code below may be useful if the position generater sometimes fails to produce an entry and the portfolio must
      // contain the required amount. It is not useful if the position generator continually fails and you get an infinite loop.
      //while (position == null) {
      //  position = getPositionGenerator().createPosition();
      //}
      if (position != null) {
        node.addPosition(position);
      }
    }
    return node;
  }
View Full Code Here

    return _nameGenerator;
  }

  @Override
  public PortfolioNode createPortfolioNode() {
    final SimplePortfolioNode node = new SimplePortfolioNode(getNameGenerator().createName());
    for (PortfolioNodeGenerator childNodeGenerator : _childNodes) {
      final PortfolioNode childNode = childNodeGenerator.createPortfolioNode();
      if (childNode != null) {
        node.addChildNode(childNode);
      }
    }
    return node;
  }
View Full Code Here

    } else {
      aggId = createSyntheticIdentifier();
    }
    String aggPortfolioName = buildPortfolioName(inputPortfolio.getName());
    List<Position> flattenedPortfolio = flatten(inputPortfolio);
    final SimplePortfolioNode root = new SimplePortfolioNode(createSyntheticIdentifier(), buildPortfolioName("Portfolio"));
    SimplePortfolio aggPortfolio = new SimplePortfolio(aggId, aggPortfolioName, root);
    aggregate(root, flattenedPortfolio, new ArrayDeque<AggregationFunction<?>>(_aggregationFunctions));
    aggPortfolio.setAttributes(inputPortfolio.getAttributes());
    return aggPortfolio;
  }
View Full Code Here

          buckets.put(name, list);
        }
      }
    }
    for (String bucketName : buckets.keySet()) {
      SimplePortfolioNode newNode = new SimplePortfolioNode();
      newNode.setUniqueId(createSyntheticIdentifier());
      newNode.setParentNodeId(inputNode.getUniqueId());
      newNode.setName(bucketName);
      inputNode.addChildNode(newNode);
      List<Position> bucket = buckets.get(bucketName);
      Collections.sort(bucket, nextFunction.getPositionComparator());
      if (functionList.isEmpty() || bucket.isEmpty()) { //IGN-138 - don't build huge empty portfolios
        for (Position position : bucket) {
          newNode.addPosition(position);
        }
      } else {
        aggregate(newNode, bucket, new ArrayDeque<AggregationFunction<?>>(functionList)); // make a copy for each bucket.
      }
    }
View Full Code Here

    }
    SavePortfolio savePortfolio = new SavePortfolio(newFixedThreadPool, portfolioMaster, positionMaster);
    if (split) {
      for (PortfolioNode portfolioNode : aggregatedPortfolio.getRootNode().getChildNodes()) {
        String splitPortfolioName = portfolioName + " (" + aggregationName + " " + portfolioNode.getName() + ")";
        SimplePortfolioNode root = new SimplePortfolioNode("root");
        root.addChildNode(portfolioNode);
        Portfolio splitPortfolio = new SimplePortfolio(splitPortfolioName, root);
        splitPortfolio.setAttributes(aggregatedPortfolio.getAttributes());
        s_logger.info("Saving split portfolio " + portfolioName + "...");
        savePortfolio.savePortfolio(splitPortfolio, true);
      }
View Full Code Here

    return _nameGenerator;
  }

  public Portfolio createPortfolio() {
    final PortfolioNode root = getRootNodeGenerator().createPortfolioNode();
    final SimplePortfolioNode rootNode;
    if (root instanceof SimplePortfolioNode) {
      rootNode = (SimplePortfolioNode) root;
    } else {
      rootNode = new SimplePortfolioNode(root);
    }
    return new SimplePortfolio(getNameGenerator().createName(), rootNode);
  }
View Full Code Here

    }
    return true;
  }

  protected SimplePortfolioNode filter(final PortfolioNode inputPortfolioNode) {
    final SimplePortfolioNode newPortfolioNode = new SimplePortfolioNode();
    newPortfolioNode.setUniqueId(createSyntheticIdentifier());
    newPortfolioNode.setName(inputPortfolioNode.getName());
    for (Position position : inputPortfolioNode.getPositions()) {
      if (acceptPosition(position)) {
        newPortfolioNode.addPosition(position);
      }
    }
    for (PortfolioNode portfolioNode : inputPortfolioNode.getChildNodes()) {
      final SimplePortfolioNode filteredPortfolioNode = filter(portfolioNode);
      if (acceptPortfolioNode(filteredPortfolioNode)) {
        filteredPortfolioNode.setParentNodeId(newPortfolioNode.getUniqueId());
        newPortfolioNode.addChildNode(filteredPortfolioNode);
      }
    }
    return newPortfolioNode;
  }
View Full Code Here

    7        |_pos
    8        |_child3
    9          |_pos
    10         |_pos
    */
    SimplePortfolioNode portfolioRoot = new SimplePortfolioNode();
    portfolioRoot.addPosition(new SimplePosition());
    SimplePortfolioNode portfolioChild1 = new SimplePortfolioNode();
    portfolioChild1.addPosition(new SimplePosition());
    portfolioChild1.addPosition(new SimplePosition());
    SimplePortfolioNode portfolioChild2 = new SimplePortfolioNode();
    portfolioChild2.addPosition(new SimplePosition());
    portfolioChild2.addPosition(new SimplePosition());
    SimplePortfolioNode portfolioChild3 = new SimplePortfolioNode();
    portfolioChild3.addPosition(new SimplePosition());
    portfolioChild3.addPosition(new SimplePosition());
    portfolioRoot.addChildNode(portfolioChild1);
    portfolioChild1.addChildNode(portfolioChild2);
    portfolioChild2.addChildNode(portfolioChild3);

    AnalyticsNode root = new AnalyticsNode.PortfolioNodeBuilder(portfolioRoot).getRoot();
View Full Code Here

    |_child1
    |  |_pos
    |_child2
    4     |_pos
    */
    SimplePortfolioNode portfolioRoot = new SimplePortfolioNode();
    SimplePortfolioNode portfolioChild1 = new SimplePortfolioNode();
    portfolioChild1.addPosition(new SimplePosition());
    SimplePortfolioNode portfolioChild2 = new SimplePortfolioNode();
    portfolioChild2.addPosition(new SimplePosition());
    portfolioRoot.addChildNode(portfolioChild1);
    portfolioRoot.addChildNode(portfolioChild2);

    AnalyticsNode root = new AnalyticsNode.PortfolioNodeBuilder(portfolioRoot).getRoot();
    assertEquals(0, root.getStartRow());
View Full Code Here

TOP

Related Classes of com.opengamma.core.position.impl.SimplePortfolioNode

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.