Package com.opengamma.master.position

Examples of com.opengamma.master.position.ManageablePosition.addTrade()


      final ManageablePosition existingPosition = _securityIdToPosition.get(writtenSecurities.get(0).getUniqueId().getObjectId());
      existingPosition.setQuantity(sumPositionQuantities(existingPosition, position));

      // Add new trades to existing position's trades
      for (ManageableTrade trade : position.getTrades()) {
        existingPosition.addTrade(trade);
      }

      if (!_multithread) {
        // Save the updated existing position to the position master
        PositionDocument addedDoc = _positionMaster.update(new PositionDocument(existingPosition));
View Full Code Here


  private ManageablePosition createPosition(ManageableSecurity security, boolean includeTrade) {
    ManageablePosition position = new ManageablePosition(BigDecimal.ONE, security.getExternalIdBundle());
    if (includeTrade) {
      ManageableTrade trade = new ManageableTrade(BigDecimal.ONE, security.getExternalIdBundle(), LocalDate.now().minusDays(3), OffsetTime.now(), ExternalId.of("Cpty", "GOLDMAN"));
      position.addTrade(trade);
    }
    return position;
  }

  private static PortfolioWriter constructPortfolioWriter(String filename, boolean write,
View Full Code Here

      // Build the position and trade(s) using security[0] (underlying)
      ManageablePosition position = _rowParser.constructPosition(row, securities[0]);     
      if (position != null) {
        ManageableTrade trade = _rowParser.constructTrade(row, securities[0], position);
        if (trade != null) {
          position.addTrade(trade);
        }
      }
      return new ObjectsPair<ManageablePosition, ManageableSecurity[]>(position, securities);
     
    } else {
View Full Code Here

      if (providerIdStr != null) {
        ExternalId providerId = ExternalId.parse(providerIdStr);
        position.setProviderId(providerId);
        manageableTrade.setProviderId(providerId);
      }
      position.addTrade(manageableTrade);
      PositionDocument addedPosition = getPositionMaster().add(new PositionDocument(position));
      root.addPosition(addedPosition.getUniqueId());

      PortfolioDocument currentPortfolio = getPortfolioMaster().update(new PortfolioDocument(portfolio));
      s_logger.info("Portfolio ID {} updated", currentPortfolio.getUniqueId());
View Full Code Here

    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) {
      ManageableTrade trade = new ManageableTrade(BigDecimal.valueOf(shares), bundle, _tradeDate3, null, ExternalId.of("CPARTY", "BACS"));
      position.addTrade(trade);
    } else {
      ManageableTrade trade1 = new ManageableTrade(BigDecimal.valueOf(2000), bundle, _tradeDate1, null, ExternalId.of("CPARTY", "BACS"));
      position.addTrade(trade1);
      ManageableTrade trade2 = new ManageableTrade(BigDecimal.valueOf(shares - 2000), bundle, _tradeDate2, null, ExternalId.of("CPARTY", "BACS"));
      position.addTrade(trade2);
View Full Code Here

    if (shares <= 2000) {
      ManageableTrade trade = new ManageableTrade(BigDecimal.valueOf(shares), bundle, _tradeDate3, null, ExternalId.of("CPARTY", "BACS"));
      position.addTrade(trade);
    } else {
      ManageableTrade trade1 = new ManageableTrade(BigDecimal.valueOf(2000), bundle, _tradeDate1, null, ExternalId.of("CPARTY", "BACS"));
      position.addTrade(trade1);
      ManageableTrade trade2 = new ManageableTrade(BigDecimal.valueOf(shares - 2000), bundle, _tradeDate2, null, ExternalId.of("CPARTY", "BACS"));
      position.addTrade(trade2);
    }
    return position;
  }
View Full Code Here

      position.addTrade(trade);
    } else {
      ManageableTrade trade1 = new ManageableTrade(BigDecimal.valueOf(2000), bundle, _tradeDate1, null, ExternalId.of("CPARTY", "BACS"));
      position.addTrade(trade1);
      ManageableTrade trade2 = new ManageableTrade(BigDecimal.valueOf(shares - 2000), bundle, _tradeDate2, null, ExternalId.of("CPARTY", "BACS"));
      position.addTrade(trade2);
    }
    return position;
  }

  /**
 
View Full Code Here

    int shares = (RandomUtils.nextInt(490) + 10) * 10;
    ExternalIdBundle bundle = security.getExternalIdBundle();
   
    ManageablePosition position = new ManageablePosition(BigDecimal.valueOf(shares), bundle);
    ManageableTrade trade = new ManageableTrade(BigDecimal.valueOf(shares), bundle, LocalDate.of(2010, 12, 3), null, ExternalId.of("CPARTY", "BACS"));
    position.addTrade(trade);
  
    return position;
  }

}
View Full Code Here

    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());
      newPosition.addTrade(trade);
      ManageablePosition savedPosition = getPositionMaster().add(new PositionDocument(newPosition)).getPosition();
      portfolioNode.addPosition(savedPosition.getUniqueId());
      _portfolioMaster.update(new PortfolioDocument(portfolio));
      return savedPosition.getTrades().get(0).getUniqueId();
    } else {
View Full Code Here

    if (Objects.equal(position.getQuantity(), quantity) == false || trades != null) {
      position.setQuantity(quantity);
      position.getTrades().clear();
      for (ManageableTrade trade : trades) {
        trade.setSecurityLink(position.getSecurityLink());
        position.addTrade(trade);
      }
      doc = data().getPositionMaster().update(doc);
      data().setPosition(doc);
    }
    return WebPositionResource.uri(data());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.