@Override
public String getText(Object element)
{
TaxonomyNode node = (TaxonomyNode) element;
Security security = node.getBackingSecurity();
if (security == null)
return null;
SecurityPrice price = security.getSecurityPrice(Dates.today());
return Values.Quote.format(price.getValue());
}
});
support.addColumn(column);
column = new Column("deltashares", Messages.ColumnDeltaShares, SWT.RIGHT, 100); //$NON-NLS-1$
column.setLabelProvider(new ColumnLabelProvider()
{
@Override
public String getText(Object element)
{
TaxonomyNode node = (TaxonomyNode) element;
if (node.getParent() != null && node.getParent().isUnassignedCategory())
return null;
Security security = node.getBackingSecurity();
if (security == null)
return null;
long price = security.getSecurityPrice(Dates.today()).getValue();
long weightedPrice = Math.round(node.getWeight() * price / Classification.ONE_HUNDRED_PERCENT);
long delta = node.getParent().getTarget() - node.getParent().getActual();
long shares = weightedPrice == 0 ? 0 : Math.round(delta * Values.Share.factor() / weightedPrice);
return Values.Share.format(shares);
}