Examples of addTrade()


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

    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

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

    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

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

      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

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

    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

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

    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

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

    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

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

  private URI addPosition(BigDecimal quantity, UniqueId secUid, Collection<ManageableTrade> trades) {
    ExternalIdBundle secId = data().getSecuritySource().get(secUid).getExternalIdBundle();
    ManageablePosition position = new ManageablePosition(quantity, secId);
    for (ManageableTrade trade : trades) {
      trade.setSecurityLink(new ManageableSecurityLink(secId));
      position.addTrade(trade);
    }
    PositionDocument doc = new PositionDocument(position);
    doc = data().getPositionMaster().add(doc);
    data().setPosition(doc);
    return WebPositionResource.uri(data());
View Full Code Here

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

    Instant now = Instant.now(_posMaster.getClock());
   
    PositionDocument base = _posMaster.get(UniqueId.of("DbPos", "121", "0"));
    ManageablePosition pos = new ManageablePosition(BigDecimal.TEN, ExternalId.of("A", "B"));
    pos.setUniqueId(UniqueId.of("DbPos", "121", "0"));
    pos.addTrade(new ManageableTrade(BigDecimal.TEN, ExternalId.of("C", "D"), _now.toLocalDate(), _now.toOffsetTime().minusSeconds(500), ExternalId.of("CPS2", "CPV2")));
    PositionDocument input = new PositionDocument(pos);
   
    PositionDocument updated = _posMaster.update(input);
    assertEquals(false, base.getUniqueId().equals(updated.getUniqueId()));
    assertEquals(now, updated.getVersionFromInstant());
View Full Code Here

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

    OffsetTime tradeTime = _now.toOffsetTime().minusSeconds(500);
   
    ManageableTrade tradeA = new ManageableTrade(BigDecimal.TEN, ExternalId.of("A", "B"), tradeDate, tradeTime, ExternalId.of("CPS", "CPV"));
    tradeA.addAttribute("key11", "Value11");
    tradeA.addAttribute("key12", "Value12");
    pos1.addTrade(tradeA);
   
    ManageableTrade tradeB = new ManageableTrade(BigDecimal.TEN, ExternalId.of("C", "D"), tradeDate, tradeTime, ExternalId.of("CPS2", "CPV2"));
    tradeB.addAttribute("key21", "Value21");
    tradeB.addAttribute("key22", "Value22");
    pos1.addTrade(tradeB);
View Full Code Here

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

    pos1.addTrade(tradeA);
   
    ManageableTrade tradeB = new ManageableTrade(BigDecimal.TEN, ExternalId.of("C", "D"), tradeDate, tradeTime, ExternalId.of("CPS2", "CPV2"));
    tradeB.addAttribute("key21", "Value21");
    tradeB.addAttribute("key22", "Value22");
    pos1.addTrade(tradeB);
   
    PositionDocument doc = new PositionDocument(pos1);
    PositionDocument version1 = _posMaster.add(doc);
    assertNotNull(version1.getUniqueId());
    assertNotNull(tradeA.getUniqueId());
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.