Package com.opengamma.master.portfolio

Examples of com.opengamma.master.portfolio.PortfolioMaster


    PortfolioMaster portfolioMaster = toolContext.getPortfolioMaster();
    assertPortfolio(portfolioMaster, ExampleEquityPortfolioLoader.PORTFOLIO_NAME);
  }

  private void assertMultiCurrencySwapPortfolio(ToolContext toolContext) {
    PortfolioMaster portfolioMaster = toolContext.getPortfolioMaster();
    assertPortfolio(portfolioMaster, ExampleDatabasePopulator.MULTI_CURRENCY_SWAP_PORTFOLIO_NAME);
  }
View Full Code Here


    }
    return spotSeries.getTimeSeries().getLatestValue();
  }

  private void persistToPortfolio(final Collection<FXOptionSecurity> fxOptions, final String portfolioName) {
    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();
      fxOptionToAddDoc.setSecurity(fxOption);
      securityMaster.add(fxOptionToAddDoc);
      final ManageablePosition fxOptionPosition = new ManageablePosition(BigDecimal.ONE, fxOption.getExternalIdBundle());
      final PositionDocument addedDoc = positionMaster.add(new PositionDocument(fxOptionPosition));
      rootNode.addPosition(addedDoc.getUniqueId());
    }
    portfolioMaster.add(portfolioDoc);
  }
View Full Code Here

    new MasterPositionSource(null, null);
  }

  //-------------------------------------------------------------------------
  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);
    Portfolio testResult = test.getPortfolio(UID, VersionCorrection.LATEST);
    verify(mockPortfolio, times(1)).get(UID);
   
    assertEquals(UID, testResult.getUniqueId());
View Full Code Here

    assertEquals("V1", testResult.getAttributes().get("A1"));
    assertEquals("V2", testResult.getAttributes().get("A2"));
  }

  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")));
    manTrade.setUniqueId(UID5);
    ManageablePosition manPos = new ManageablePosition();
    manPos.setQuantity(BigDecimal.valueOf(1235));
    manPos.setSecurityLink(new ManageableSecurityLink(ExternalId.of("AA", "BB")));
    manPos.setUniqueId(UID4);
    manPos.addTrade(manTrade);
    PositionDocument posDoc = new PositionDocument(manPos);
    PositionSearchRequest posRequest = new PositionSearchRequest();
    posRequest.addPositionObjectId(UID4);
    posRequest.setVersionCorrection(VC);
    PositionSearchResult posResult = new PositionSearchResult();
    posResult.getDocuments().add(posDoc);
   
    when(mockPortfolio.get(UID)).thenReturn(prtDoc);
    when(mockPosition.search(posRequest)).thenReturn(posResult);
    MasterPositionSource test = new MasterPositionSource(mockPortfolio, mockPosition);
    Portfolio testResult = test.getPortfolio(UID, VC);
    verify(mockPortfolio, times(1)).get(UID);
    verify(mockPosition, times(1)).search(posRequest);
View Full Code Here

    assertEquals(ExternalIdBundle.of("CC", "DD"), trade.getSecurityLink().getExternalId());
  }

  //-------------------------------------------------------------------------
  public void test_getPortfolioNode_UniqueId() throws Exception {
    PortfolioMaster mockPortfolio = mock(PortfolioMaster.class);
    PositionMaster mockPosition = mock(PositionMaster.class);
   
    ManageablePortfolioNode manNode = new ManageablePortfolioNode("Node");
    manNode.setUniqueId(UID2);
    manNode.setPortfolioId(UID);
    ManageablePortfolioNode manChild = new ManageablePortfolioNode("Child");
    manChild.setUniqueId(UID3);
    manChild.setParentNodeId(UID2);
    manChild.setPortfolioId(UID);
    manNode.addChildNode(manChild);
   
    when(mockPortfolio.getNode(UID2)).thenReturn(manNode);
    MasterPositionSource test = new MasterPositionSource(mockPortfolio, mockPosition);
    PortfolioNode testResult = test.getPortfolioNode(UID2, VersionCorrection.LATEST);
    verify(mockPortfolio, times(1)).getNode(UID2);
   
    assertEquals("Node", testResult.getName());
View Full Code Here

    assertEquals(0, testResult.getChildNodes().get(0).getPositions().size());
    assertEquals(0, testResult.getChildNodes().get(0).getChildNodes().size());
  }

  public void test_getPosition() throws Exception {
    final PortfolioMaster mockPortfolio = mock(PortfolioMaster.class);
    final PositionMaster mockPosition = mock(PositionMaster.class);
    final PositionDocument doc = new PositionDocument(new ManageablePosition(BigDecimal.TEN, ExternalId.of("B", "C")));
    doc.getPosition().setUniqueId(UID);
    when(mockPosition.get(UID)).thenReturn(doc);
    MasterPositionSource test = new MasterPositionSource(mockPortfolio, mockPosition);
View Full Code Here

    assertEquals(BigDecimal.TEN, testResult.getQuantity());
    assertEquals(ExternalId.of("B", "C").toBundle(), testResult.getSecurityLink().getExternalId());
  }

  public void test_getTrade() throws Exception {
    final PortfolioMaster mockPortfolio = mock(PortfolioMaster.class);
    final PositionMaster mockPosition = mock(PositionMaster.class);
    final OffsetDateTime now = OffsetDateTime.now();
    final ManageableTrade doc = new ManageableTrade(BigDecimal.TEN, ExternalId.of("B", "C"), now.toLocalDate(), now.toOffsetTime().minusSeconds(100), ExternalId.of("CPARTY", "C100"));
    doc.setUniqueId(UID);
    when(mockPosition.getTrade(UID)).thenReturn(doc);
View Full Code Here

    PositionMaster positionMaster = new InMemoryPositionMaster();
    SecurityMaster securityMaster = new InMemorySecurityMaster();
    SecuritySource securitySource = new MasterSecuritySource(securityMaster);
   
    // Set up mock portfolio master
    PortfolioMaster portfolioMaster = mock(PortfolioMaster.class);
    PortfolioSearchRequest portSearchRequest = new PortfolioSearchRequest();
    portSearchRequest.setName(PORTFOLIO_NAME);
    PortfolioSearchResult portSearchResult = new PortfolioSearchResult();
    when(portfolioMaster.search(portSearchRequest)).thenReturn(portSearchResult);
    ManageablePortfolioNode rootNode = new ManageablePortfolioNode(PORTFOLIO_NAME);
    rootNode.setUniqueId(UniqueId.of("abc", "123"));
    ManageablePortfolio portfolio = new ManageablePortfolio(PORTFOLIO_NAME, rootNode);
    PortfolioDocument portfolioDocument = new PortfolioDocument();
    portfolioDocument.setPortfolio(portfolio);
    when(portfolioMaster.add(any(PortfolioDocument.class))).thenReturn(portfolioDocument);
   
    // file to masters
    PortfolioReader portfolioReader =
        new SingleSheetSimplePortfolioReader(PORTFOLIO_FILE, SECURITY_TYPE);
    PortfolioWriter portfolioWriter =
View Full Code Here

TOP

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

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.