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