use of name.abuchen.portfolio.snapshot.ReportingPeriod in project portfolio by buchen.
the class Issue672CapitalGainsIfSecurityIsTransferred method testPurchaseValueOfSecurityPositionWithTransfers.
@Test
public void testPurchaseValueOfSecurityPositionWithTransfers() throws IOException {
Client client = ClientFactory.load(Issue371PurchaseValueWithTransfers.class.getResourceAsStream(// $NON-NLS-1$
"Issue672CapitalGainsIfSecurityIsTransferred.xml"));
CurrencyConverter converter = new TestCurrencyConverter();
Portfolio secondPortfolio = client.getPortfolios().get(1);
ReportingPeriod period = new // $NON-NLS-1$
ReportingPeriod.FromXtoY(// $NON-NLS-1$
LocalDate.parse("2016-01-01"), // $NON-NLS-1$
LocalDate.parse("2017-01-01"));
SecurityPerformanceSnapshot snapshot = SecurityPerformanceSnapshot.create(client, converter, secondPortfolio, period);
assertThat(snapshot.getRecords().size(), is(1));
SecurityPerformanceRecord record = snapshot.getRecords().get(0);
assertThat(record.getMarketValue(), is(Money.of(CurrencyUnit.EUR, Values.Money.factorize(971.41))));
assertThat(record.getFifoCost(), is(Money.of(CurrencyUnit.EUR, Values.Money.factorize(883.1))));
assertThat(record.getCapitalGainsOnHoldings(), is(Money.of(CurrencyUnit.EUR, Values.Money.factorize(88.31))));
assertThat(record.getCapitalGainsOnHoldingsPercent(), is(IsCloseTo.closeTo(0.1d, 0.0000000001)));
}
use of name.abuchen.portfolio.snapshot.ReportingPeriod in project portfolio by buchen.
the class IssueCurrencyGainsRoundingError method testPurchaseValueOfSecurityPositionWithTransfers.
@Test
public void testPurchaseValueOfSecurityPositionWithTransfers() throws IOException {
Client client = ClientFactory.load(IssueCurrencyGainsRoundingError.class.getResourceAsStream(// $NON-NLS-1$
"IssueCurrencyGainsRoundingError.xml"));
ReportingPeriod period = new // $NON-NLS-1$
ReportingPeriod.FromXtoY(// $NON-NLS-1$
LocalDate.parse("2015-01-09"), // $NON-NLS-1$
LocalDate.parse("2016-01-09"));
CurrencyConverter converter = new TestCurrencyConverter();
ClientPerformanceSnapshot snapshot = new ClientPerformanceSnapshot(client, converter, period);
MutableMoney currencyGains = MutableMoney.of(converter.getTermCurrency());
currencyGains.subtract(snapshot.getValue(CategoryType.INITIAL_VALUE));
currencyGains.subtract(snapshot.getValue(CategoryType.CAPITAL_GAINS));
currencyGains.subtract(snapshot.getValue(CategoryType.EARNINGS));
currencyGains.add(snapshot.getValue(CategoryType.FEES));
currencyGains.add(snapshot.getValue(CategoryType.TAXES));
currencyGains.add(snapshot.getValue(CategoryType.TRANSFERS));
currencyGains.add(snapshot.getValue(CategoryType.FINAL_VALUE));
assertThat(snapshot.getCategoryByType(CategoryType.CURRENCY_GAINS).getValuation(), is(currencyGains.toMoney()));
}
use of name.abuchen.portfolio.snapshot.ReportingPeriod in project portfolio by buchen.
the class PerformanceView method reportingPeriodUpdated.
@Override
public void reportingPeriodUpdated() {
ReportingPeriod period = getReportingPeriod();
CurrencyConverter converter = new CurrencyConverterImpl(factory, getClient().getBaseCurrency());
Client filteredClient = clientFilter.getSelectedFilter().filter(getClient());
ClientPerformanceSnapshot snapshot = new ClientPerformanceSnapshot(filteredClient, converter, period);
try {
calculation.getTree().setRedraw(false);
calculation.setInput(snapshot);
calculation.expandAll();
calculation.getTree().getParent().layout();
} finally {
calculation.getTree().setRedraw(true);
}
snapshotStart.setInput(snapshot.getStartClientSnapshot(), clientFilter.getSelectedFilter());
snapshotEnd.setInput(snapshot.getEndClientSnapshot(), clientFilter.getSelectedFilter());
earnings.setInput(snapshot.getEarnings());
earningsByAccount.setInput(new GroupEarningsByAccount(snapshot).getItems());
taxes.setInput(snapshot.getTaxes());
fees.setInput(snapshot.getFees());
}
use of name.abuchen.portfolio.snapshot.ReportingPeriod in project portfolio by buchen.
the class StatementOfAssetsViewer method addPerformanceColumns.
private void addPerformanceColumns(List<ReportingPeriod> options) {
ReportingPeriodLabelProvider labelProvider;
// $NON-NLS-1$
Column column = new Column("ttwror", Messages.ColumnTWROR, SWT.RIGHT, 80);
labelProvider = new ReportingPeriodLabelProvider(SecurityPerformanceRecord::getTrueTimeWeightedRateOfReturn);
column.setOptions(new ReportingPeriodColumnOptions(Messages.ColumnTTWROR_Option, options));
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setDescription(Messages.ColumnTWROR_Description);
column.setLabelProvider(labelProvider);
column.setSorter(ColumnViewerSorter.create(new ElementComparator(labelProvider)));
column.setVisible(false);
support.addColumn(column);
// $NON-NLS-1$
column = new Column("irr", Messages.ColumnIRR, SWT.RIGHT, 80);
labelProvider = new ReportingPeriodLabelProvider(SecurityPerformanceRecord::getIrr);
column.setOptions(new ReportingPeriodColumnOptions(Messages.ColumnIRRPerformanceOption, options));
column.setMenuLabel(Messages.ColumnIRR_MenuLabel);
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setLabelProvider(labelProvider);
column.setSorter(ColumnViewerSorter.create(new ElementComparator(labelProvider)));
column.setVisible(false);
support.addColumn(column);
Function<Stream<Object>, Object> sum = elements -> elements.map(e -> (Money) e).collect(MoneyCollectors.sum(client.getBaseCurrency()));
// $NON-NLS-1$
column = new Column("capitalgains", Messages.ColumnCapitalGains, SWT.RIGHT, 80);
labelProvider = new ReportingPeriodLabelProvider(SecurityPerformanceRecord::getCapitalGainsOnHoldings, sum, true);
column.setOptions(new ReportingPeriodColumnOptions(Messages.ColumnCapitalGains_Option, options));
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setDescription(Messages.ColumnCapitalGains_Description);
column.setLabelProvider(labelProvider);
column.setSorter(ColumnViewerSorter.create(new ElementComparator(labelProvider)));
column.setVisible(false);
support.addColumn(column);
// $NON-NLS-1$
column = new Column("capitalgains%", Messages.ColumnCapitalGainsPercent, SWT.RIGHT, 80);
labelProvider = new ReportingPeriodLabelProvider(SecurityPerformanceRecord::getCapitalGainsOnHoldingsPercent);
column.setOptions(new ReportingPeriodColumnOptions(Messages.ColumnCapitalGainsPercent_Option, options));
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setDescription(Messages.ColumnCapitalGainsPercent_Description);
column.setLabelProvider(labelProvider);
column.setSorter(ColumnViewerSorter.create(new ElementComparator(labelProvider)));
column.setVisible(false);
support.addColumn(column);
// $NON-NLS-1$
column = new Column("capitalgainsmvavg", Messages.ColumnCapitalGainsMovingAverage, SWT.RIGHT, 80);
labelProvider = new ReportingPeriodLabelProvider(SecurityPerformanceRecord::getCapitalGainsOnHoldingsMovingAverage, sum, true);
column.setOptions(new ReportingPeriodColumnOptions(Messages.ColumnCapitalGainsMovingAverage_Option, options));
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setDescription(Messages.ColumnCapitalGainsMovingAverage_Description);
column.setLabelProvider(labelProvider);
column.setSorter(ColumnViewerSorter.create(new ElementComparator(labelProvider)));
column.setVisible(false);
support.addColumn(column);
// $NON-NLS-1$
column = new Column("capitalgainsmvavg%", Messages.ColumnCapitalGainsMovingAveragePercent, SWT.RIGHT, 80);
labelProvider = new ReportingPeriodLabelProvider(SecurityPerformanceRecord::getCapitalGainsOnHoldingsMovingAveragePercent);
column.setOptions(new ReportingPeriodColumnOptions(Messages.ColumnCapitalGainsMovingAveragePercent_Option, options));
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setDescription(Messages.ColumnCapitalGainsMovingAveragePercent_Description);
column.setLabelProvider(labelProvider);
column.setSorter(ColumnViewerSorter.create(new ElementComparator(labelProvider)));
column.setVisible(false);
support.addColumn(column);
// $NON-NLS-1$
column = new Column("delta", Messages.ColumnAbsolutePerformance_MenuLabel, SWT.RIGHT, 80);
labelProvider = new ReportingPeriodLabelProvider(SecurityPerformanceRecord::getDelta, sum, true);
column.setOptions(new ReportingPeriodColumnOptions(Messages.ColumnAbsolutePerformance_Option, options));
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setDescription(Messages.ColumnAbsolutePerformance_Description);
column.setLabelProvider(labelProvider);
column.setSorter(ColumnViewerSorter.create(new ElementComparator(labelProvider)));
column.setVisible(false);
support.addColumn(column);
// $NON-NLS-1$
column = new Column("delta%", Messages.ColumnAbsolutePerformancePercent_MenuLabel, SWT.RIGHT, 80);
labelProvider = new ReportingPeriodLabelProvider(SecurityPerformanceRecord::getDeltaPercent);
column.setOptions(new ReportingPeriodColumnOptions(Messages.ColumnAbsolutePerformancePercent_Option, options));
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setDescription(Messages.ColumnAbsolutePerformancePercent_Description);
column.setLabelProvider(labelProvider);
column.setSorter(ColumnViewerSorter.create(new ElementComparator(labelProvider)));
column.setVisible(false);
support.addColumn(column);
}
use of name.abuchen.portfolio.snapshot.ReportingPeriod in project portfolio by buchen.
the class ExchangeRateWidget method createControl.
@Override
public Composite createControl(Composite parent, DashboardResources resources) {
Composite container = new Composite(parent, SWT.NONE);
container.setBackground(parent.getBackground());
GridLayoutFactory.fillDefaults().numColumns(1).margins(5, 5).applyTo(container);
title = new Label(container, SWT.NONE);
title.setText(getWidget().getLabel());
GridDataFactory.fillDefaults().grab(true, false).applyTo(title);
indicator = new Label(container, SWT.NONE);
indicator.setFont(resources.getKpiFont());
// $NON-NLS-1$
indicator.setText("");
GridDataFactory.fillDefaults().grab(true, false).applyTo(indicator);
InfoToolTip.attach(indicator, () -> {
ReportingPeriod period = get(ReportingPeriodConfig.class).getReportingPeriod();
ExchangeRateTimeSeries series = get(ExchangeRateSeriesConfig.class).getSeries();
Optional<ExchangeRate> rate = series.lookupRate(period.getEndDate());
return rate.isPresent() ? MessageFormat.format(Messages.TooltipDateOfExchangeRate, formatter.format(rate.get().getTime())) : // $NON-NLS-1$
"";
});
return container;
}
Aggregations