{
Account pseudoAccount = new Account();
pseudoAccount.setName(""); //$NON-NLS-1$
pseudoClient.addAccount(pseudoAccount);
Portfolio pseudoPortfolio = new Portfolio();
pseudoPortfolio.setReferenceAccount(pseudoAccount);
pseudoClient.addPortfolio(pseudoPortfolio);
pseudoClient.addSecurity(security);
for (Portfolio p : client.getPortfolios())
{
for (PortfolioTransaction t : p.getTransactions())
{
if (t.getSecurity().equals(security))
{
long shares = value(t.getShares(), weight);
long amount = value(t.getAmount(), weight);
long fees = value(t.getFees(), weight);
long taxes = value(t.getTaxes(), weight);
switch (t.getType())
{
case BUY:
case TRANSFER_IN:
{
pseudoPortfolio.addTransaction(new PortfolioTransaction(t.getDate(), t.getSecurity(),
PortfolioTransaction.Type.DELIVERY_INBOUND, shares, amount, fees, taxes));
break;
}
case SELL:
case TRANSFER_OUT:
pseudoPortfolio.addTransaction(new PortfolioTransaction(t.getDate(), t.getSecurity(),
PortfolioTransaction.Type.DELIVERY_OUTBOUND, shares, amount, fees, taxes));
break;
case DELIVERY_INBOUND:
case DELIVERY_OUTBOUND:
pseudoPortfolio.addTransaction(new PortfolioTransaction(t.getDate(), t.getSecurity(), t
.getType(), shares, amount, fees, taxes));
break;
default:
throw new UnsupportedOperationException();
}