Package com.opengamma.core.position.impl

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


    return _counterPartyGenerator;
  }

  public static Position createPositionFromTrade(final ManageableTrade trade) {
    if (trade != null) {
      final SimplePosition position = new SimplePosition(trade.getQuantity(), trade.getSecurityLink().getExternalId());
      position.addTrade(trade);
      return position;
    } else {
      return null;
    }
  }
View Full Code Here


  }

  @Test
  public void flatPortfolio() {
    SimplePortfolioNode portfolioRoot = new SimplePortfolioNode("");
    portfolioRoot.addPosition(new SimplePosition());
    portfolioRoot.addPosition(new SimplePosition());
    portfolioRoot.addPosition(new SimplePosition());
    portfolioRoot.addPosition(new SimplePosition());
    portfolioRoot.addPosition(new SimplePosition());

    AnalyticsNode root = new AnalyticsNode.PortfolioNodeBuilder(portfolioRoot).getRoot();
    assertEquals(0, root.getStartRow());
    assertEquals(5, root.getEndRow()); // 1 node for the root and one each for the positions
    assertTrue(root.getChildren().isEmpty());
View Full Code Here

    3   |_child1
    4      |_pos
    5      |_pos
    */
    SimplePortfolioNode portfolioChild = new SimplePortfolioNode();
    portfolioChild.addPosition(new SimplePosition());
    portfolioChild.addPosition(new SimplePosition());
    SimplePortfolioNode portfolioRoot = new SimplePortfolioNode("");
    portfolioRoot.addChildNode(portfolioChild);
    portfolioRoot.addPosition(new SimplePosition());
    portfolioRoot.addPosition(new SimplePosition());

    AnalyticsNode root = new AnalyticsNode.PortfolioNodeBuilder(portfolioRoot).getRoot();
    assertEquals(0, root.getStartRow());
    assertEquals(5, root.getEndRow());
    assertEquals(1, root.getChildren().size());
View Full Code Here

    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

    |_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

    |_pos2
    5     |_trade3
    */
    EquitySecurity security = new EquitySecurity("exchange", "exchangeCode", "companyName", Currency.USD);
    SimplePortfolioNode portfolioRoot = new SimplePortfolioNode();
    SimplePosition position1 = new SimplePosition();
    SimpleSecurityLink securityLink = new SimpleSecurityLink();
    securityLink.setTarget(security);
    position1.setSecurityLink(securityLink);
    position1.addTrade(new SimpleTrade());
    position1.addTrade(new SimpleTrade());
    SimplePosition position2 = new SimplePosition();
    position2.setSecurityLink(securityLink);
    position2.addTrade(new SimpleTrade());
    portfolioRoot.addPosition(position1);
    portfolioRoot.addPosition(position2);

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

    FXForwardSecurity security = new FXForwardSecurity(Currency.GBP, 123,
                                                       Currency.USD, 321,
                                                       LocalDate.of(2012, 12, 21).atTime(11, 0).atZone(ZoneOffset.UTC),
                                                       ExternalId.of("Reg", "ABC"));
    SimplePortfolioNode portfolioRoot = new SimplePortfolioNode();
    SimplePosition position1 = new SimplePosition();
    SimpleSecurityLink securityLink = new SimpleSecurityLink();
    securityLink.setTarget(security);
    position1.setSecurityLink(securityLink);
    position1.addTrade(new SimpleTrade());
    SimplePosition position2 = new SimplePosition();
    position2.setSecurityLink(securityLink);
    position2.addTrade(new SimpleTrade());
    portfolioRoot.addPosition(position1);
    portfolioRoot.addPosition(position2);

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

  public void test_resolve_trade() {
    final OffsetDateTime now = OffsetDateTime.now();
    final InMemorySecuritySource secSource = new InMemorySecuritySource();
    final MockPositionSource posSource = new MockPositionSource();
    final SimplePortfolio portfolio = new SimplePortfolio(UniqueId.of("Test", "1"), "Name");
    final SimplePosition position = new SimplePosition(UniqueId.of("Test", "1"), new BigDecimal(1), ExternalIdBundle.EMPTY);
    final SimpleTrade trade = new SimpleTrade(new SimpleSecurityLink(), new BigDecimal(1), new SimpleCounterparty(ExternalId.of("CPARTY", "C100")), now.toLocalDate(), now.toOffsetTime());
    trade.setUniqueId(UniqueId.of("TradeScheme", "1"));
    position.addTrade(trade);
    portfolio.getRootNode().addPosition(position);
    posSource.addPortfolio(portfolio);
    final DefaultComputationTargetResolver test = new DefaultComputationTargetResolver(secSource, posSource);
    final ComputationTargetSpecification spec = ComputationTargetSpecification.of(trade);
    final ComputationTarget expected = new ComputationTarget(ComputationTargetType.TRADE, trade);
View Full Code Here

    return nodes;
  }

  private void addPositions(final SimplePortfolioNode node, final int num) {
    for (int i = 0; i < num; i++) {
      node.addPosition(new SimplePosition(nextUniqueId(), new BigDecimal(10), ExternalId.of("Security", "Foo")));
    }
  }
View Full Code Here

    assertPositionEquals(original, position);
    return message;
  }

  public void testPosition() {
    final FudgeMsg message = runPositionTest(new SimplePosition(nextUniqueId(), new BigDecimal(100), ExternalIdBundle.of(ExternalId.of("Scheme 1", "Id 1"), ExternalId
        .of("Scheme 2", "Id 2"))));
    assertEquals(0, countParents(message));
  }
View Full Code Here

TOP

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

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.