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