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