Package com.opengamma.master.position

Examples of com.opengamma.master.position.ManageablePosition


    assertEquals(200, response.getStatus());

    final PositionDocument positionDocument = _positionMaster.get(uid);
    assertNotNull(positionDocument);

    final ManageablePosition position = positionDocument.getPosition();
    assertEquals(BigDecimal.valueOf(QUANTITY), position.getQuantity());
    final List<ManageableTrade> trades = position.getTrades();
    assertTrue(trades.isEmpty());
  }
View Full Code Here


    assertEquals(200, response.getStatus());

    final PositionDocument positionDocument = _positionMaster.get(uid);
    assertNotNull(positionDocument);

    final ManageablePosition position = positionDocument.getPosition();
    assertEquals(BigDecimal.valueOf(QUANTITY), position.getQuantity());
    final List<ManageableTrade> trades = position.getTrades();
    assertTrue(trades.isEmpty());
  }
View Full Code Here

    assertEquals(OffsetTime.of(LocalTime.of(13, 30), ZoneOffset.UTC), testTrade.getPremiumTime());
    assertEquals(BigDecimal.valueOf(30), testTrade.getQuantity());
    assertEquals(ExternalId.of(AbstractTradeBuilder.CPTY_SCHEME, "cptyName"), testTrade.getCounterpartyExternalId());
    assertTrue(testTrade.getAttributes().isEmpty());

    ManageablePosition testPosition = _positionMaster.get(testTrade.getParentPositionId()).getPosition();
    assertEquals(APPLE_BUNDLE, testPosition.getSecurityLink().getExternalId());
    assertEquals(BigDecimal.valueOf(50), testPosition.getQuantity());
    assertEquals(2, testPosition.getTrades().size());
    assertEquals(testTrade, testPosition.getTrades().get(1));

    ManageablePortfolio testPortfolio = _portfolioMaster.get(_savedNode.getPortfolioId()).getPortfolio();
    ManageablePortfolioNode testNode = testPortfolio.getRootNode().getChildNodes().get(0);
    assertEquals(1, testNode.getPositionIds().size());
    assertEquals(_savedPosition.getUniqueId().getObjectId(), testNode.getPositionIds().get(0));
View Full Code Here

  /**
   * update a position that doesn't have any trades. position's quantity should match trade and trade should be added
   */
  @Test
  public void updatePositionWithNoTrades() {
    ManageablePosition position = new ManageablePosition(BigDecimal.valueOf(42), APPLE_SECURITY.getExternalIdBundle());
    ManageablePosition savedPosition = _positionMaster.add(new PositionDocument(position)).getPosition();
    assertEquals(BigDecimal.valueOf(42), savedPosition.getQuantity());

    _tradeBuilder.updatePosition(createTradeData("AAPL US Equity", null), savedPosition.getUniqueId());
    ManageablePosition updatedPosition = _positionMaster.get(savedPosition.getUniqueId().getObjectId(),
                                                             VersionCorrection.LATEST).getPosition();
    assertEquals(BigDecimal.valueOf(30), updatedPosition.getQuantity());
    assertEquals(1, updatedPosition.getTrades().size());
    ManageableTrade trade = updatedPosition.getTrades().get(0);
    assertEquals(LocalDate.of(2012, 12, 21), trade.getTradeDate());
    assertEquals(OffsetTime.of(LocalTime.of(14, 25), ZoneOffset.UTC), trade.getTradeTime());
    assertEquals(APPLE_BUNDLE, trade.getSecurityLink().getExternalId());
    assertEquals(1234d, trade.getPremium());
    assertEquals(Currency.USD, trade.getPremiumCurrency());
View Full Code Here

    _securitySource.addSecurity(added.getSecurity());
  }

  protected void populatePositionMaster() {
    for (final ManageableTrade trade : _trades) {
      final ManageablePosition manageablePosition = new ManageablePosition(trade.getQuantity(), SEC_ID);
      manageablePosition.addTrade(trade);
      final PositionDocument positionDocument = new PositionDocument(manageablePosition);
      _positionMaster.add(positionDocument);
    }
  }
View Full Code Here

    final PositionSearchResult searchResult = _positionMaster.search(request);
    assertNotNull(searchResult);
    final List<PositionDocument> docs = searchResult.getDocuments();
    assertNotNull(docs);
    assertEquals(1, docs.size());
    final ManageablePosition position = docs.get(0).getPosition();
    assertEquals(BigDecimal.TEN, position.getQuantity());
    assertEquals(SECURITY_LINK, position.getSecurityLink());
    assertTrue(position.getTrades().isEmpty());
  }
View Full Code Here

    final PositionSearchResult searchResult = _positionMaster.search(request);
    assertNotNull(searchResult);
    final List<PositionDocument> docs = searchResult.getDocuments();
    assertNotNull(docs);
    assertEquals(1, docs.size());
    final ManageablePosition position = docs.get(0).getPosition();
    assertEquals(BigDecimal.TEN, position.getQuantity());
    assertEquals(SECURITY_LINK, position.getSecurityLink());

    final List<ManageableTrade> trades = position.getTrades();
    assertEquals(3, trades.size());
    for (final ManageableTrade trade : trades) {
      assertEquals(SECURITY_LINK, trade.getSecurityLink());
      trade.setUniqueId(null);
      trade.setSecurityLink(new ManageableSecurityLink(SEC_ID));
View Full Code Here

    origTrade.setPremium(10.0);
    origTrade.setPremiumCurrency(Currency.USD);
    origTrade.setPremiumDate(LocalDate.parse("2011-12-08"));
    origTrade.setPremiumTime(OffsetTime.of(LocalTime.of(15, 4), ZONE_OFFSET));

    final ManageablePosition manageablePosition = new ManageablePosition(origTrade.getQuantity(), EQUITY_SECURITY.getExternalIdBundle());
    manageablePosition.addTrade(origTrade);
    final PositionDocument addedPos = _positionMaster.add(new PositionDocument(manageablePosition));
    final UniqueId uid = addedPos.getUniqueId();
    return uid;
  }
View Full Code Here

        subIndustryNode = new ManageablePortfolioNode("Sub industry " + subIndustry);
        industryNode.addChildNode(subIndustryNode);
      }

      // create the position and add it to the master
      final ManageablePosition position = createPositionAndTrade(security);
      final PositionDocument addedPosition = addPosition(position);

      // add the position reference (the unique identifier) to portfolio
      subIndustryNode.addPosition(addedPosition.getUniqueId());
    }
View Full Code Here

    s_logger.debug("Creating position {}", security);
    final int shares = (RandomUtils.nextInt(490) + 10) * 10;

    final ExternalIdBundle bundle = security.getExternalIdBundle(); // we could add an identifier pointing back to the original source database if we're doing an ETL.

    final ManageablePosition position = new ManageablePosition(BigDecimal.valueOf(shares), bundle);

    // create random trades that add up in shares to the position they're under (this is not enforced by the system)
    if (shares <= 2000) {
      final ManageableTrade trade = new ManageableTrade(BigDecimal.valueOf(shares), bundle, LocalDate.of(2010, 12, 3), null, ExternalId.of("CPARTY", "BACS"));
      position.addTrade(trade);
    } else {
      final ManageableTrade trade1 = new ManageableTrade(BigDecimal.valueOf(2000), bundle, LocalDate.of(2010, 12, 1), null, ExternalId.of("CPARTY", "BACS"));
      position.addTrade(trade1);
      final ManageableTrade trade2 = new ManageableTrade(BigDecimal.valueOf(shares - 2000), bundle, LocalDate.of(2010, 12, 2), null, ExternalId.of("CPARTY", "BACS"));
      position.addTrade(trade2);
    }
    return position;
  }
View Full Code Here

TOP

Related Classes of com.opengamma.master.position.ManageablePosition

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.