Package com.opengamma.core.position

Examples of com.opengamma.core.position.PortfolioNode


   */
  public String toLongString() {
    StrBuilder childBuf = new StrBuilder(1024);
    childBuf.append("[");
    for (int i = 0; i < getChildNodes().size(); i++) {
      PortfolioNode child = getChildNodes().get(i);
      if (child instanceof SimplePortfolioNode) {
        childBuf.append(((SimplePortfolioNode) child).toLongString());
      } else {
        childBuf.append(child.toString());
      }
      if (i != getChildNodes().size() - 1) {
        childBuf.append(",");
      }
    }
View Full Code Here


  @Override
  public String convertValueToText(Object value, boolean selected,
      boolean expanded, boolean leaf, int row, boolean hasFocus) {
    if (value != null) {
      if (value instanceof PortfolioNode) {
        PortfolioNode portfolioNode = (PortfolioNode) value;
        return portfolioNode.getName();
      } else if (value instanceof Position) {
        Position position = (Position) value;
        ExternalIdBundle bundle = position.getSecurityLink().getExternalId().withCustomIdOrdering(_idBundleComparator);
        if (!bundle.isEmpty()) {
          return bundle.iterator().next() + " (" + position.getQuantity() + ")";
View Full Code Here

      return null;
    }
    if (parent instanceof Position) {
      throw new OpenGammaRuntimeException("Unexpected call to getChild on a position");
    } else if (parent instanceof PortfolioNode) {
      PortfolioNode node = (PortfolioNode) parent;
      if (index < node.getPositions().size()) {
        return (node.getPositions().toArray())[index];
      } else {
        return (node.getChildNodes().toArray())[index - node.getPositions().size()];
      }
    } else {
      throw new OpenGammaRuntimeException("Unexpected call to getChild on a unexpected type " + parent);
    }
  }
View Full Code Here

      return 0;
    }
    if (parent instanceof Position) {
      return 0;
    } else if (parent instanceof PortfolioNode) {
      PortfolioNode node = (PortfolioNode) parent;
      return node.size();
    } else {
      throw new OpenGammaRuntimeException("Unexpected call to getChild on a unexpected type " + parent);
    }
  }
View Full Code Here

      return 0;
    }
    if (parent instanceof Position) {
      return 0;
    } else if (parent instanceof PortfolioNode) {
      PortfolioNode node = (PortfolioNode) parent;
      if (child instanceof Position) {
        return new ArrayList<Position>(node.getPositions()).indexOf(child);
      } else {
        return new ArrayList<PortfolioNode>(node.getChildNodes()).indexOf(child) + node.getPositions().size();
      }
    } else {
      throw new OpenGammaRuntimeException("Unexpected call to getChild on a unexpected type " + parent);
    }
  }
View Full Code Here

*/
public class PortfolioExchangeTradedDailyPnLFunction extends AbstractPortfolioDailyPnLFunction {

  @Override
  public boolean canApplyTo(FunctionCompilationContext context, ComputationTarget target) {
    final PortfolioNode node = target.getPortfolioNode();
    final Set<Position> allPositions = PositionAccumulator.getAccumulatedPositions(node);
    for (Position position : allPositions) {
      Security positionSecurity = position.getSecurity();
      if (!FinancialSecurityUtils.isExchangeTraded(positionSecurity) && !(positionSecurity instanceof BondSecurity)) {
        return false;
View Full Code Here

*/
public class PortfolioEquityPnLFunction extends AbstractPortfolioPnLFunction {

  @Override
  public boolean canApplyTo(final FunctionCompilationContext context, final ComputationTarget target) {
    final PortfolioNode node = target.getPortfolioNode();
    final Set<Position> allPositions = PositionAccumulator.getAccumulatedPositions(node);
    for (final Position position : allPositions) {
      if (position.getSecurity() instanceof EquitySecurity) {
        for (final Trade trade : position.getTrades()) {
          if (!(trade.getSecurity() instanceof EquitySecurity)) {
View Full Code Here

  }

  @Override
  public Object getChild(Object parent, int index) {
    if (parent instanceof PortfolioNode) {
      PortfolioNode portfolioNode = (PortfolioNode) parent;
      List<PortfolioNode> childNodes = portfolioNode.getChildNodes();
      if (index < childNodes.size()) {
        return childNodes.get(index);
      } else {
        // we get a position
        List<Position> positions = portfolioNode.getPositions();
        int positionIndex = index - childNodes.size();
        if (positionIndex < positions.size()) {
          return positions.get(positionIndex);
        } else {
          return null;
View Full Code Here

  }

  @Override
  public int getChildCount(Object parent) {
    if (parent instanceof PortfolioNode) {
      PortfolioNode portfolioNode = (PortfolioNode) parent;
      List<PortfolioNode> childNodes = portfolioNode.getChildNodes();
      return portfolioNode.getChildNodes().size() + portfolioNode.getPositions().size();
    } else if (parent instanceof Position) {
      Position position = (Position) parent;
      return position.getTrades().size() == 0 ? 1 : position.getTrades().size();
    } else if (parent instanceof Trade) {
      Trade trade = (Trade) parent;
View Full Code Here

  }

  @Override
  public boolean isLeaf(Object node) {
    if (node instanceof PortfolioNode) {
      PortfolioNode portfolioNode = (PortfolioNode) node;
      return portfolioNode.getChildNodes().size() == 0 && portfolioNode.getPositions().size() == 0;
    } else if (node instanceof Position) {
      Position position = (Position) node;
      return position.getTrades().size() == 0 && position.getSecurity() == null;
    } else if (node instanceof Trade) {
      Trade trade = (Trade) node;
View Full Code Here

TOP

Related Classes of com.opengamma.core.position.PortfolioNode

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.