Package com.opengamma.master.position

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


    OffsetTime tradeTime = _now.toOffsetTime().minusSeconds(500);
   
    ManageableTrade trade1 = new ManageableTrade(BigDecimal.TEN, ExternalId.of("A", "B"), tradeDate, tradeTime, ExternalId.of("CPS", "CPV"));
    trade1.addAttribute("key11", "value11");
    trade1.addAttribute("key12", "value12");
    position.addTrade(trade1);
   
    ManageableTrade trade2 = new ManageableTrade(BigDecimal.TEN, ExternalId.of("C", "D"), tradeDate, tradeTime, ExternalId.of("CPS2", "CPV2"));
    trade2.addAttribute("key21", "value21");
    trade2.addAttribute("key22", "value22");
    position.addTrade(trade2);
View Full Code Here


    position.addTrade(trade1);
   
    ManageableTrade trade2 = new ManageableTrade(BigDecimal.TEN, ExternalId.of("C", "D"), tradeDate, tradeTime, ExternalId.of("CPS2", "CPV2"));
    trade2.addAttribute("key21", "value21");
    trade2.addAttribute("key22", "value22");
    position.addTrade(trade2);
   
    PositionDocument doc = new PositionDocument();
    doc.setPosition(position);
    _posMaster.add(doc);
    assertNotNull(trade1.getUniqueId());
View Full Code Here

  }

  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

    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

    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);
View Full Code Here

    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

      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

    return trade;
  }

  private ManageablePosition createPosition(final ManageableSecurity security) {
    final ManageablePosition position = new ManageablePosition(BigDecimal.ONE, getBundle(security));
    position.addTrade(createTrade(security));
    return position;
  }
 
  private ManageablePortfolioNode createNode(final String nodeName, final Collection<? extends ManageableSecurity> securities) {
    final ManageablePortfolioNode node = new ManageablePortfolioNode(nodeName);
View Full Code Here

    return new PortfolioPosition(convertTradeToPosition(trade, security[0]), security, parentPath);
  }

  private ManageablePosition convertTradeToPosition(Trade trade, ManageableSecurity security) {
    ManageablePosition manageablePosition = new ManageablePosition(trade.getQuantity(), security.getExternalIdBundle());
    manageablePosition.addTrade(convertTrade(trade, security));
    return manageablePosition;
  }

  private ManageablePosition convertPosition(Position position, Security security, BigDecimal tradeQuantity) {
View Full Code Here

      manageablePosition.setProviderId(externalSystemId.toExternalId());
    }

    List<Trade> trades = position.getTrades();
    for (Trade trade : nullCheckIterable(trades)) {
      manageablePosition.addTrade(convertTrade(trade, security));
    }

    manageablePosition.setAttributes(position.getAdditionalAttributes());

    return manageablePosition;
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.