Package com.opengamma.integration.copier.portfolio

Examples of com.opengamma.integration.copier.portfolio.SimplePortfolioCopier


        getCommandLine().hasOption(WRITE_OPT),
        getCommandLine().hasOption(INCLUDE_TRADES_OPT)
        );

    // Construct portfolio copier
    PortfolioCopier portfolioCopier = new SimplePortfolioCopier();

    // Create visitor for verbose/quiet mode
    PortfolioCopierVisitor portfolioCopierVisitor;
    if (getCommandLine().hasOption(VERBOSE_OPT)) {
      portfolioCopierVisitor = new VerbosePortfolioCopierVisitor();
    } else {
      portfolioCopierVisitor = new QuietPortfolioCopierVisitor();
    }

    // Call the portfolio loader with the supplied arguments
    portfolioCopier.copy(portfolioReader, portfolioWriter, portfolioCopierVisitor);

    // close stuff
    portfolioReader.close();
    portfolioWriter.close();
  }
View Full Code Here


        getCommandLine().hasOption(WRITE_OPT),
        getCommandLine().hasOption(INCLUDE_TRADES_OPT)
    );
   
    // Construct portfolio copier
    PortfolioCopier portfolioCopier = new SimplePortfolioCopier();
       
    // Create visitor for verbose/quiet mode
    PortfolioCopierVisitor portfolioCopierVisitor;
    if (getCommandLine().hasOption(VERBOSE_OPT)) {
      portfolioCopierVisitor = new VerbosePortfolioCopierVisitor();
    } else {
      portfolioCopierVisitor = new QuietPortfolioCopierVisitor();
    }
   
    // Call the portfolio loader with the supplied arguments
    portfolioCopier.copy(portfolioReader, portfolioWriter, portfolioCopierVisitor);

    // close stuff
    portfolioReader.close();
    portfolioWriter.close();
  }
View Full Code Here

      String name = portfolioReader.getPortfolioName();

      String portfolioName = name != null ? name : _suggestedPortfolioName;
      PortfolioWriter portfolioWriter =
          constructPortfolioWriter(_toolContext, portfolioName, _write, _mergePositions, _keepCurrentPositions);
      SimplePortfolioCopier portfolioCopier = new SimplePortfolioCopier(_structure);

      // Create visitor for verbose/quiet mode
      PortfolioCopierVisitor portfolioCopierVisitor =
          _verbose ? new VerbosePortfolioCopierVisitor() : new QuietPortfolioCopierVisitor();

      // Call the portfolio loader with the supplied arguments
      portfolioCopier.copy(portfolioReader, portfolioWriter, portfolioCopierVisitor);

      // close stuff
      portfolioReader.close();
      portfolioWriter.close();
    }
View Full Code Here

    }
  }

  private void xmlPortfolioCopy(PortfolioReader portfolioReader) {

    SimplePortfolioCopier copier = new SimplePortfolioCopier(null);
    final PortfolioWriter portfolioWriter = new MasterPortfolioWriter(portfolioReader.getPortfolioName(),
                                                                      _portfolioMaster, _positionMaster,
                                                                      _securityMaster, false, false, true);
    // Call the portfolio loader with the supplied arguments
    copier.copy(portfolioReader, portfolioWriter);
    // close stuff
    portfolioReader.close();
    portfolioWriter.close();
  }
View Full Code Here

  private static final String SECURITY_TYPE = "Equity";
 
  @Test
  public void testCsvToMastersToCsv() throws Exception {
   
    PortfolioCopier portfolioCopier = new SimplePortfolioCopier();

    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 =
        new MasterPortfolioWriter(PORTFOLIO_NAME, portfolioMaster, positionMaster, securityMaster, false, false, false);
    portfolioCopier.copy(portfolioReader, portfolioWriter);
    portfolioReader.close();
    portfolioWriter.close();

    portSearchResult.setDocuments(Collections.singletonList(portfolioDocument));
   
    // Masters to file
    portfolioReader = new MasterPortfolioReader(PORTFOLIO_NAME, portfolioMaster, positionMaster, securitySource);
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    portfolioWriter = new SingleSheetSimplePortfolioWriter(SheetFormat.CSV, outputStream, SECURITY_TYPE);
    portfolioCopier.copy(portfolioReader, portfolioWriter);
    portfolioReader.close();
    portfolioWriter.close();

    // Compare source and destination
    try (CSVReader sourceReader = new CSVReader(new InputStreamReader(new FileInputStream(PORTFOLIO_FILE)))) {
View Full Code Here

TOP

Related Classes of com.opengamma.integration.copier.portfolio.SimplePortfolioCopier

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.