Package com.opengamma.master.position

Examples of com.opengamma.master.position.PositionDocument$Meta


  }

  @Test
  public void testGetPositionWithoutTrade() throws Exception {
    final ManageablePosition manageablePosition = new ManageablePosition(BigDecimal.valueOf(50), SEC_ID);
    final PositionDocument addedPos = _positionMaster.add(new PositionDocument(manageablePosition));

    final WebPositionResource positionResource = _webPositionsResource.findPosition(addedPos.getUniqueId().toString());
    final String json = positionResource.getJSON();
    assertNotNull(json);
    assertJSONObjectEquals(loadJson("com/opengamma/web/position/positionWithoutTrades.txt"), new JSONObject(json));
  }
View Full Code Here


    trade2.setPremiumCurrency(Currency.GBP);
    trade2.setPremiumDate(tradeDate.plusDays(10));
    trade2.setPremiumTime(tradeTime.plusHours(1));
    position.getTrades().add(trade2);
   
    PositionDocument doc = new PositionDocument();
    doc.setPosition(position);
    _posMaster.add(doc);
    assertNotNull(trade1.getUniqueId());
    assertNotNull(trade2.getUniqueId());
   
    PositionSearchRequest requestByTrade = new PositionSearchRequest();
View Full Code Here

    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());
    assertNotNull(trade2.getUniqueId());
   
    PositionSearchRequest requestByTrade = new PositionSearchRequest();
View Full Code Here

    final Response response = positionResource.putJSON(QUANTITY.toString(), getTradesJson());
    assertNotNull(response);
    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();
    assertEquals(3, trades.size());
    for (final ManageableTrade trade : trades) {
      assertEquals(SECURITY_LINK, trade.getSecurityLink());
View Full Code Here

    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());
    assertNotNull(trade2.getUniqueId());
   
    PositionSearchRequest requestByTrade = new PositionSearchRequest();
View Full Code Here

    final Response response = positionResource.putJSON(QUANTITY.toString(), null);
    assertNotNull(response);
    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

    final Response response = positionResource.putJSON(QUANTITY.toString(), EMPTY_TRADES);
    assertNotNull(response);
    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

    position.addTrade(new ManageableTrade(quantity,
                                          APPLE_BUNDLE,
                                          LocalDate.of(2012, 12, 1),
                                          OffsetTime.of(LocalTime.of(9, 30), ZoneOffset.UTC),
                                          ExternalId.of(AbstractTradeBuilder.CPTY_SCHEME, "existingCpty")));
    _savedPosition = _positionMaster.add(new PositionDocument(position)).getPosition();
    ManageablePortfolioNode root = new ManageablePortfolioNode("root");
    ManageablePortfolioNode node = new ManageablePortfolioNode("node");
    node.addPosition(_savedPosition.getUniqueId());
    root.addChildNode(node);
    ManageablePortfolio portfolio = new ManageablePortfolio("portfolio", root);
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();
View Full Code Here

        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());
    }

    // adds the complete tree structure to the master
    addPortfolio(portfolio);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.master.position.PositionDocument$Meta

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.