Package com.opengamma.integration.copier.portfolio.writer

Examples of com.opengamma.integration.copier.portfolio.writer.PortfolioWriter


  @Override
  protected void doRun() {     
    IntegrationToolContext context = getToolContext();

    // Create portfolio writer
    PortfolioWriter portfolioWriter = constructPortfolioWriter(
        getCommandLine().getOptionValue(PORTFOLIO_NAME_OPT),
        context.getPortfolioMaster(),
        context.getPositionMaster(),
        context.getSecurityMaster(),
        getCommandLine().hasOption(WRITE_OPT),
        getCommandLine().hasOption(OVERWRITE_OPT)
    );

    // Construct portfolio reader
    PortfolioReader portfolioReader = constructPortfolioReader(
        getCommandLine().getOptionValue(FILE_NAME_OPT),
        context.getSecurityProvider()
    );
   
    // Create portfolio copier
    ResolvingPortfolioCopier portfolioCopier = new ResolvingPortfolioCopier(
        context.getHistoricalTimeSeriesMaster(),
        context.getHistoricalTimeSeriesProvider(),
        context.getBloombergReferenceDataProvider(),
        getOptionValue(TIME_SERIES_DATAPROVIDER_OPT, "CMPL"),
        getCommandLine().getOptionValues(TIME_SERIES_DATAFIELD_OPT) == null ?
            new String[]{"PX_LAST"} : getCommandLine().getOptionValues(TIME_SERIES_DATAFIELD_OPT)
    );
   
    // 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


    List<ManageablePosition> positions = loadSomePositions(getCommandLine().hasOption(INCLUDE_TRADES_OPT));
    // Construct portfolio reader
    PortfolioReader portfolioReader = new MyPortfolioReader(positions);

    // Create portfolio writer
    PortfolioWriter portfolioWriter = constructPortfolioWriter(
        getCommandLine().getOptionValue(FILE_NAME_OPT),
        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

    PortfolioReader portfolioReader = constructPortfolioReader(
        getCommandLine().getOptionValue(PORTFOLIO_NAME_OPT)
    );

    // Create portfolio writer
    PortfolioWriter portfolioWriter = constructPortfolioWriter(
        getCommandLine().getOptionValue(FILE_NAME_OPT),
        getCommandLine().getOptionValue(SECURITY_TYPE_OPT),
        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

      // Get the name of the portfolio from the reader if it supplies one
      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

        ? s_securityTypes
        : getCommandLine().getOptionValues(SECURITY_TYPE_OPT);

    // Create portfolio writers to write header rows
    for (String securityType : securityTypes) {
      PortfolioWriter portfolioWriter = new SingleSheetSimplePortfolioWriter(securityType + ".csv",
          JodaBeanRowParser.newJodaBeanRowParser(securityType));
      portfolioWriter.close();
    }
  }
View Full Code Here

      final ResolvingPortfolioCopier copier = new ResolvingPortfolioCopier(_historicalTimeSeriesMaster,
                                                                           _historicalTimeSeriesProvider,
                                                                           _referenceDataProvider,
                                                                           dataProvider,
                                                                           dataFields);
      final PortfolioWriter portfolioWriter =
          new MasterPortfolioWriter(portfolioName, _portfolioMaster, _positionMaster, _securityMaster, false, false, true);
      SheetFormat format = getFormatForFileName(fileName);
      RowParser rowParser = new ExchangeTradedRowParser(_securityProvider);
      final PortfolioReader portfolioReader = new SingleSheetSimplePortfolioReader(format, fileStream, rowParser);
      StreamingOutput streamingOutput = new StreamingOutput() {
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

  @Override
  protected void doRun() {
    IntegrationToolContext context = getToolContext();

    // Create portfolio writer
    PortfolioWriter portfolioWriter = new PrettyPrintingPortfolioWriter(getCommandLine().hasOption(VERBOSE_OPT));

    // Construct portfolio reader
    PortfolioReader portfolioReader = new MasterPortfolioReader(
        getCommandLine().getOptionValue(PORTFOLIO_NAME_OPT),
        context.getPortfolioMaster(),
        context.getPositionMaster(),
        context.getSecuritySource());
   
    // Create portfolio copier
    ResolvingPortfolioCopier portfolioCopier = new ResolvingPortfolioCopier(
        context.getHistoricalTimeSeriesMaster(),
        context.getHistoricalTimeSeriesProvider(),
        context.getBloombergReferenceDataProvider(),
        getOptionValue(TIME_SERIES_DATAPROVIDER_OPT, "CMPL"),
        getCommandLine().getOptionValues(TIME_SERIES_DATAFIELD_OPT) == null ?
            new String[]{"PX_LAST"} : getCommandLine().getOptionValues(TIME_SERIES_DATAFIELD_OPT)
    );
   
    // 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

    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)))) {
      try (CSVReader destReader = new CSVReader(new InputStreamReader(new ByteArrayInputStream(outputStream.toByteArray())))) {
        int j = 1;
View Full Code Here

TOP

Related Classes of com.opengamma.integration.copier.portfolio.writer.PortfolioWriter

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.