use of name.abuchen.portfolio.snapshot.security.SecurityPerformanceRecord in project portfolio by buchen.
the class SecuritiesPerformanceView method createCommonColumns.
private void createCommonColumns() {
// shares held
// $NON-NLS-1$
Column column = new Column("shares", Messages.ColumnSharesOwned, SWT.RIGHT, 80);
column.setLabelProvider(new // NOSONAR
SharesLabelProvider() {
@Override
public Long getValue(Object e) {
return ((SecurityPerformanceRecord) e).getSharesHeld();
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "sharesHeld"));
recordColumns.addColumn(column);
// security name
column = new NameColumn();
recordColumns.addColumn(column);
// cost value - fifo
// $NON-NLS-1$
column = new Column("pv", Messages.ColumnPurchaseValue, SWT.RIGHT, 75);
column.setDescription(Messages.ColumnPurchaseValue_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Money.format(((SecurityPerformanceRecord) r).getFifoCost(), getClient().getBaseCurrency());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "fifoCost"));
recordColumns.addColumn(column);
// cost value - moving average
// $NON-NLS-1$
column = new Column("pvmvavg", Messages.ColumnPurchaseValueMovingAverage, SWT.RIGHT, 75);
column.setMenuLabel(Messages.ColumnPurchaseValueMovingAverage_MenuLabel);
column.setDescription(Messages.ColumnPurchaseValueMovingAverage_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Money.format(((SecurityPerformanceRecord) r).getMovingAverageCost(), getClient().getBaseCurrency());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "movingAverageCost"));
column.setVisible(false);
recordColumns.addColumn(column);
// cost value per share - fifo
// $NON-NLS-1$
column = new Column("pp", Messages.ColumnPurchasePrice, SWT.RIGHT, 75);
column.setDescription(Messages.ColumnPurchasePrice_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Quote.format(((SecurityPerformanceRecord) r).getFifoCostPerSharesHeld(), getClient().getBaseCurrency());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "fifoCostPerSharesHeld"));
recordColumns.addColumn(column);
// cost value per share - moving average
// $NON-NLS-1$
column = new Column("ppmvavg", Messages.ColumnPurchasePriceMovingAverage, SWT.RIGHT, 75);
column.setMenuLabel(Messages.ColumnPurchasePriceMovingAverage_MenuLabel);
column.setDescription(Messages.ColumnPurchasePriceMovingAverage_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Quote.format(((SecurityPerformanceRecord) r).getMovingAverageCostPerSharesHeld(), getClient().getBaseCurrency());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "movingAverageCostPerSharesHeld"));
column.setVisible(false);
recordColumns.addColumn(column);
// latest / current quote
// $NON-NLS-1$
column = new Column("quote", Messages.ColumnQuote, SWT.RIGHT, 75);
column.setDescription(Messages.ColumnQuote_DescriptionEndOfReportingPeriod);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
SecurityPerformanceRecord record = (SecurityPerformanceRecord) element;
return Values.Quote.format(record.getQuote(), getClient().getBaseCurrency());
}
@Override
public String getToolTipText(Object element) {
SecurityPerformanceRecord record = (SecurityPerformanceRecord) element;
return MessageFormat.format(Messages.TooltipQuoteAtDate, getText(element), Values.Date.format(record.getLatestSecurityPrice().getDate()));
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "fifoCostPerSharesHeld"));
recordColumns.addColumn(column);
// market value
// $NON-NLS-1$
column = new Column("mv", Messages.ColumnMarketValue, SWT.RIGHT, 75);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Money.format(((SecurityPerformanceRecord) r).getMarketValue(), getClient().getBaseCurrency());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "marketValue"));
recordColumns.addColumn(column);
// fees paid
// $NON-NLS-1$
column = new Column("fees", Messages.ColumnFees, SWT.RIGHT, 80);
column.setDescription(Messages.ColumnFees_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Money.format(((SecurityPerformanceRecord) r).getFees(), getClient().getBaseCurrency());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "fees"));
column.setVisible(false);
recordColumns.addColumn(column);
// taxes paid
// $NON-NLS-1$
column = new Column("taxes", Messages.ColumnTaxes, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Money.format(((SecurityPerformanceRecord) r).getTaxes(), getClient().getBaseCurrency());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "taxes"));
column.setVisible(false);
recordColumns.addColumn(column);
// isin
column = new IsinColumn();
column.getEditingSupport().addListener(new MarkDirtyListener(this));
column.setVisible(false);
recordColumns.addColumn(column);
// note
column = new NoteColumn();
column.getEditingSupport().addListener(new MarkDirtyListener(this));
column.setVisible(false);
recordColumns.addColumn(column);
}
use of name.abuchen.portfolio.snapshot.security.SecurityPerformanceRecord in project portfolio by buchen.
the class SecuritiesPerformanceView method createRiskColumns.
private void createRiskColumns() {
// $NON-NLS-1$
Column column = new Column("mdd", Messages.ColumnMaxDrawdown, SWT.RIGHT, 60);
column.setMenuLabel(Messages.LabelMaxDrawdown);
column.setGroupLabel(Messages.LabelRiskIndicators);
column.setVisible(false);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Percent2.formatNonZero(((SecurityPerformanceRecord) r).getMaxDrawdown());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "maxDrawdown"));
recordColumns.addColumn(column);
// $NON-NLS-1$
column = new Column("mddduration", Messages.ColumnMaxDrawdownDuration, SWT.RIGHT, 60);
column.setMenuLabel(Messages.LabelMaxDrawdownDuration);
column.setGroupLabel(Messages.LabelRiskIndicators);
column.setVisible(false);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return String.valueOf(((SecurityPerformanceRecord) r).getMaxDrawdownDuration());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "maxDrawdownDuration"));
recordColumns.addColumn(column);
// $NON-NLS-1$
column = new Column("vola", Messages.LabelVolatility, SWT.RIGHT, 80);
column.setGroupLabel(Messages.LabelRiskIndicators);
column.setVisible(false);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Percent2.format(((SecurityPerformanceRecord) r).getVolatility());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "volatility"));
recordColumns.addColumn(column);
// $NON-NLS-1$
column = new Column("semivola", Messages.LabelSemiVolatility, SWT.RIGHT, 80);
column.setGroupLabel(Messages.LabelRiskIndicators);
column.setVisible(false);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Percent2.format(((SecurityPerformanceRecord) r).getSemiVolatility());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "semiVolatility"));
recordColumns.addColumn(column);
}
use of name.abuchen.portfolio.snapshot.security.SecurityPerformanceRecord in project portfolio by buchen.
the class SecuritiesPerformanceView method createTopTable.
@Override
protected void createTopTable(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
TableColumnLayout layout = new TableColumnLayout();
container.setLayout(layout);
records = new TableViewer(container, SWT.FULL_SELECTION);
recordColumns = new ShowHideColumnHelper(SecuritiesPerformanceView.class.getName(), getClient(), getPreferenceStore(), records, layout);
updateTitle(getDefaultTitle());
recordColumns.addListener(() -> updateTitle(getDefaultTitle()));
ColumnViewerToolTipSupport.enableFor(records, ToolTip.NO_RECREATE);
ColumnEditingSupport.prepare(records);
createCommonColumns();
createDividendColumns();
addPerformanceColumns();
createRiskColumns();
createAdditionalColumns();
recordColumns.createColumns();
records.getTable().setHeaderVisible(true);
records.getTable().setLinesVisible(true);
records.setContentProvider(ArrayContentProvider.getInstance());
//
records.addDragSupport(//
DND.DROP_MOVE, //
new Transfer[] { SecurityTransfer.getTransfer() }, new SecurityDragListener(records));
hookContextMenu(records.getTable(), this::fillContextMenu);
records.addSelectionChangedListener(new // NOSONAR
ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
SecurityPerformanceRecord record = (SecurityPerformanceRecord) ((IStructuredSelection) event.getSelection()).getFirstElement();
Security security = null;
List<Transaction> transactionList = null;
if (record != null) {
transactionList = record.getTransactions();
security = record.getSecurity();
}
transactions.setInput(transactionList);
transactions.refresh();
chart.updateChart(security);
latest.setInput(security);
}
});
records.addSelectionChangedListener(event -> {
SecurityPerformanceRecord record = (SecurityPerformanceRecord) ((IStructuredSelection) event.getSelection()).getFirstElement();
if (record != null)
selectionService.setSelection(new SecuritySelection(getClient(), record.getSecurity()));
});
records.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (recordFilter.isEmpty())
return true;
for (Predicate<SecurityPerformanceRecord> predicate : recordFilter) {
if (!predicate.test((SecurityPerformanceRecord) element))
return false;
}
return true;
}
});
reportingPeriodUpdated();
}
use of name.abuchen.portfolio.snapshot.security.SecurityPerformanceRecord in project portfolio by buchen.
the class SecuritiesPerformanceView method fillContextMenu.
private // NOSONAR
void fillContextMenu(// NOSONAR
IMenuManager manager) {
Object selection = ((IStructuredSelection) records.getSelection()).getFirstElement();
if (!(selection instanceof SecurityPerformanceRecord))
return;
Security security = ((SecurityPerformanceRecord) selection).getSecurity();
new SecurityContextMenu(this).menuAboutToShow(manager, security);
}
use of name.abuchen.portfolio.snapshot.security.SecurityPerformanceRecord in project portfolio by buchen.
the class SecuritiesPerformanceView method addPerformanceColumns.
private void addPerformanceColumns() {
// $NON-NLS-1$
Column column = new Column("twror", Messages.ColumnTWROR, SWT.RIGHT, 80);
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setMenuLabel(Messages.ColumnTWROR_Description);
column.setLabelProvider(new NumberColorLabelProvider<>(Values.Percent2, r -> ((SecurityPerformanceRecord) r).getTrueTimeWeightedRateOfReturn()));
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "trueTimeWeightedRateOfReturn"));
recordColumns.addColumn(column);
// internal rate of return
// $NON-NLS-1$
column = new Column("izf", Messages.ColumnIRR, SWT.RIGHT, 80);
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setMenuLabel(Messages.ColumnIRR_MenuLabel);
column.setLabelProvider(new NumberColorLabelProvider<>(Values.Percent2, r -> ((SecurityPerformanceRecord) r).getIrr()));
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "irr"));
recordColumns.addColumn(column);
// $NON-NLS-1$
column = new Column("capitalgains", Messages.ColumnCapitalGains, SWT.RIGHT, 80);
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setDescription(Messages.ColumnCapitalGains_Description);
column.setLabelProvider(new MoneyColorLabelProvider(element -> ((SecurityPerformanceRecord) element).getCapitalGainsOnHoldings(), getClient().getBaseCurrency()));
column.setVisible(false);
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "capitalGainsOnHoldings"));
recordColumns.addColumn(column);
// $NON-NLS-1$
column = new Column("capitalgains%", Messages.ColumnCapitalGainsPercent, SWT.RIGHT, 80);
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setDescription(Messages.ColumnCapitalGainsPercent_Description);
column.setLabelProvider(new NumberColorLabelProvider<>(Values.Percent2, r -> ((SecurityPerformanceRecord) r).getCapitalGainsOnHoldingsPercent()));
column.setVisible(false);
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "capitalGainsOnHoldingsPercent"));
recordColumns.addColumn(column);
// $NON-NLS-1$
column = new Column("capitalgainsmvavg", Messages.ColumnCapitalGainsMovingAverage, SWT.RIGHT, 80);
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setMenuLabel(Messages.ColumnCapitalGainsMovingAverage_MenuLabel);
column.setDescription(Messages.ColumnCapitalGainsMovingAverage_Description);
column.setLabelProvider(new MoneyColorLabelProvider(element -> ((SecurityPerformanceRecord) element).getCapitalGainsOnHoldingsMovingAverage(), getClient().getBaseCurrency()));
column.setVisible(false);
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "capitalGainsOnHoldingsMovingAverage"));
recordColumns.addColumn(column);
// $NON-NLS-1$
column = new Column("capitalgainsmvavg%", Messages.ColumnCapitalGainsMovingAveragePercent, SWT.RIGHT, 80);
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setMenuLabel(Messages.ColumnCapitalGainsMovingAveragePercent_MenuLabel);
column.setDescription(Messages.ColumnCapitalGainsMovingAveragePercent_Description);
column.setLabelProvider(new NumberColorLabelProvider<>(Values.Percent2, r -> ((SecurityPerformanceRecord) r).getCapitalGainsOnHoldingsMovingAveragePercent()));
column.setVisible(false);
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "capitalGainsOnHoldingsMovingAveragePercent"));
recordColumns.addColumn(column);
// delta
// $NON-NLS-1$
column = new Column("delta", Messages.ColumnAbsolutePerformance, SWT.RIGHT, 80);
column.setDescription(Messages.ColumnAbsolutePerformance_Description);
column.setMenuLabel(Messages.ColumnAbsolutePerformance_MenuLabel);
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setLabelProvider(new MoneyColorLabelProvider(element -> ((SecurityPerformanceRecord) element).getDelta(), getClient().getBaseCurrency()));
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "delta"));
recordColumns.addColumn(column);
// delta percent
// $NON-NLS-1$
column = new Column("delta%", Messages.ColumnAbsolutePerformancePercent, SWT.RIGHT, 80);
column.setDescription(Messages.ColumnAbsolutePerformancePercent_Description);
column.setMenuLabel(Messages.ColumnAbsolutePerformancePercent_MenuLabel);
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setLabelProvider(new NumberColorLabelProvider<>(Values.Percent2, r -> ((SecurityPerformanceRecord) r).getDeltaPercent()));
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "deltaPercent"));
column.setVisible(false);
recordColumns.addColumn(column);
}
Aggregations