Package com.opengamma.master.portfolio

Examples of com.opengamma.master.portfolio.ManageablePortfolio


  }
 
  @Override
  public Portfolio getPortfolio(UniqueId uniqueId, VersionCorrection versionCorrection) {
    ArgumentChecker.notNull(uniqueId, "uniqueId");
    final ManageablePortfolio manPrt = getPortfolioMaster().get(uniqueId).getPortfolio();
    final SimplePortfolio prt = new SimplePortfolio(manPrt.getUniqueId(), manPrt.getName());
    convertNode(manPrt.getRootNode(), prt.getRootNode(), versionCorrection);
    copyAttributes(manPrt, prt);
    return prt;
  }
View Full Code Here


  @Override
  public Portfolio getPortfolio(ObjectId objectId, VersionCorrection versionCorrection) {
    ArgumentChecker.notNull(objectId, "objectId");
    ArgumentChecker.notNull(versionCorrection, "versionCorrection");
    final ManageablePortfolio manPrt = getPortfolioMaster().get(objectId, versionCorrection).getPortfolio();
    final SimplePortfolio prt = new SimplePortfolio(manPrt.getUniqueId(), manPrt.getName());
    convertNode(manPrt.getRootNode(), prt.getRootNode(), versionCorrection);
    copyAttributes(manPrt, prt);
    return prt;
  }
View Full Code Here

    final PortfolioMaster portfolioMaster = getToolContext().getPortfolioMaster();
    final PositionMaster positionMaster = getToolContext().getPositionMaster();
    final SecurityMaster securityMaster = getToolContext().getSecurityMaster();

    final ManageablePortfolioNode rootNode = new ManageablePortfolioNode(portfolioName);
    final ManageablePortfolio portfolio = new ManageablePortfolio(portfolioName, rootNode);
    final PortfolioDocument portfolioDoc = new PortfolioDocument();
    portfolioDoc.setPortfolio(portfolio);

    for (final FXOptionSecurity fxOption : fxOptions) {
      final SecurityDocument fxOptionToAddDoc = new SecurityDocument();
View Full Code Here

  }

  //-------------------------------------------------------------------------
  @Test
  public void testGetPortfolio() {
    final ManageablePortfolio target = new ManageablePortfolio("Portfolio");
    final PortfolioDocument result = new PortfolioDocument(target);
    when(_underlying.get(OID, VersionCorrection.LATEST)).thenReturn(result);
   
    Response test = _resource.get(null, null);
    assertEquals(Status.OK.getStatusCode(), test.getStatus());
View Full Code Here

    assertSame(result, test.getEntity());
  }

  @Test
  public void testUpdatePortfolio() {
    final ManageablePortfolio target = new ManageablePortfolio("Portfolio");
    final PortfolioDocument request = new PortfolioDocument(target);
    request.setUniqueId(OID.atVersion("1"));
   
    final PortfolioDocument result = new PortfolioDocument(target);
    result.setUniqueId(OID.atVersion("1"));
View Full Code Here

  }

  //-------------------------------------------------------------------------
  @Test
  public void testAddPortfolio() {
    final ManageablePortfolio target = new ManageablePortfolio("Portfolio A");
    target.getRootNode().setName("RootNode");
    target.getRootNode().addChildNode(new ManageablePortfolioNode("Child"));
    final PortfolioDocument request = new PortfolioDocument(target);
   
    final PortfolioDocument result = new PortfolioDocument(target);
    result.setUniqueId(UID);
    when(_underlying.add(same(request))).thenReturn(result);
View Full Code Here

    return generatePortfolio("Test");
  }
 
  private static ManageablePortfolio generatePortfolio(String name) {
    ManageablePortfolioNode rootNode = generatePortfolioNodes(name, 2, 2);
    return new ManageablePortfolio(name, rootNode);
  }
View Full Code Here

  }
 
  //-------------------------------------------------------------------------
  @Test
  public void test_add_emptyMaster() {
    ManageablePortfolio origPortfolio = generatePortfolio();
    PortfolioDocument addedDoc = _emptyMaster.add(new PortfolioDocument(origPortfolio));
   
    assertNotNull(addedDoc.getVersionFromInstant());
   
    assertEquals("MemPrt", addedDoc.getUniqueId().getScheme());
    assertEquals("1", addedDoc.getUniqueId().getValue());
   
    ManageablePortfolio addedPortfolio = addedDoc.getPortfolio();
    assertNotNull(addedPortfolio);
    assertSame(origPortfolio, addedPortfolio);
    assertEquals(addedDoc.getUniqueId(), addedPortfolio.getUniqueId());   
    assertAddedPortfolioNodes(addedPortfolio.getRootNode(), addedPortfolio.getUniqueId(), null);
  }
View Full Code Here

  public void test_getPortfolio_UniqueId() throws Exception {
    PortfolioMaster mockPortfolio = mock(PortfolioMaster.class);
    PositionMaster mockPosition = mock(PositionMaster.class);
   
    ManageablePortfolioNode manNode = example(false);
    ManageablePortfolio manPrt = new ManageablePortfolio("Hello", manNode);
    manPrt.addAttribute("A1", "V1");
    manPrt.addAttribute("A2", "V2");
    manPrt.setUniqueId(UID);
   
    PortfolioDocument prtDoc = new PortfolioDocument(manPrt);
   
    when(mockPortfolio.get(UID)).thenReturn(prtDoc);
    MasterPositionSource test = new MasterPositionSource(mockPortfolio, mockPosition);
View Full Code Here

  public void test_getPortfolio_UniqueId_instants_children() throws Exception {
    PortfolioMaster mockPortfolio = mock(PortfolioMaster.class);
    PositionMaster mockPosition = mock(PositionMaster.class);
   
    ManageablePortfolioNode manNode = example(true);
    ManageablePortfolio manPrt = new ManageablePortfolio("Hello", manNode);
    manPrt.setUniqueId(UID);
    PortfolioDocument prtDoc = new PortfolioDocument(manPrt);
   
    ManageableTrade manTrade = new ManageableTrade();
    manTrade.setQuantity(BigDecimal.valueOf(1234));
    manTrade.setSecurityLink(new ManageableSecurityLink(ExternalId.of("CC", "DD")));
View Full Code Here

TOP

Related Classes of com.opengamma.master.portfolio.ManageablePortfolio

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.