class OtcTradeBuilder extends AbstractTradeBuilder {

  @SuppressWarnings("deprecation")
  UniqueId addTrade(BeanDataSource tradeData,
                                  BeanDataSource securityData,
                                  BeanDataSource underlyingData,
                                  UniqueId nodeId) {
    /*
    validate:
      underlying is present
      underlying type is correct
    */
    ManageableSecurity underlying = buildUnderlying(underlyingData);
    ManageableSecurity security;
    if (underlying == null) {
      security = BlotterUtils.buildSecurity(securityData);
    } else {
      ManageableSecurity savedUnderlying = getSecurityMaster().add(new SecurityDocument(underlying)).getSecurity();
      security = buildSecurity(securityData, savedUnderlying);
    }
    ManageableSecurity savedSecurity = getSecurityMaster().add(new SecurityDocument(security)).getSecurity();
    ManageableTrade trade = buildTrade(tradeData);
    trade.setSecurityLink(new ManageableSecurityLink(savedSecurity.getUniqueId()));
    ManageablePosition position = new ManageablePosition();
    position.setQuantity(BigDecimal.ONE);
    position.setSecurityLink(new ManageableSecurityLink(trade.getSecurityLink()));
    position.setTrades(Lists.newArrayList(trade));
    ManageablePosition savedPosition = getPositionMaster().add(new PositionDocument(position)).getPosition();
    ManageableTrade savedTrade = savedPosition.getTrades().get(0);

    PortfolioSearchRequest searchRequest = new PortfolioSearchRequest();
    searchRequest.addNodeObjectId(nodeId.getObjectId());
    PortfolioSearchResult searchResult = getPortfolioMaster().search(searchRequest);
    ManageablePortfolio portfolio = searchResult.getSinglePortfolio();
    ManageablePortfolioNode node = findNode(portfolio, nodeId);
    node.addPosition(savedPosition.getUniqueId());
    getPortfolioMaster().update(new PortfolioDocument(portfolio));
    return savedTrade.getUniqueId();
  }

    OtcTradeBuilder(PositionMaster positionMaster,
                                PortfolioMaster portfoioMaster,
                                SecurityMaster securityMaster,
                                Set<MetaBean> metaBeans,
                                StringConvert stringConvert);

}