use of name.abuchen.portfolio.snapshot.ReportingPeriod in project portfolio by buchen.
the class StatementOfAssetsViewer method addDividendColumns.
private void addDividendColumns(List<ReportingPeriod> options) {
ReportingPeriodLabelProvider labelProvider;
// $NON-NLS-1$
Column column = new Column("sumdiv", Messages.ColumnDividendSum, SWT.RIGHT, 80);
Function<Stream<Object>, Object> collector = elements -> elements.map(e -> (Money) e).collect(MoneyCollectors.sum(client.getBaseCurrency()));
labelProvider = new ReportingPeriodLabelProvider(SecurityPerformanceRecord::getSumOfDividends, collector, false);
// $NON-NLS-1$
column.setOptions(new ReportingPeriodColumnOptions(Messages.ColumnDividendSum + " {0}", options));
column.setGroupLabel(Messages.GroupLabelDividends);
column.setMenuLabel(Messages.ColumnDividendSum_MenuLabel);
column.setLabelProvider(labelProvider);
column.setSorter(ColumnViewerSorter.create(new ElementComparator(labelProvider)));
column.setVisible(false);
support.addColumn(column);
// $NON-NLS-1$
column = new Column("d%", Messages.ColumnDividendTotalRateOfReturn, SWT.RIGHT, 80);
labelProvider = new ReportingPeriodLabelProvider(SecurityPerformanceRecord::getTotalRateOfReturnDiv, null, false);
// $NON-NLS-1$
column.setOptions(new ReportingPeriodColumnOptions(Messages.ColumnDividendTotalRateOfReturn + " {0}", options));
column.setGroupLabel(Messages.GroupLabelDividends);
column.setDescription(Messages.ColumnDividendTotalRateOfReturn_Description);
column.setLabelProvider(labelProvider);
column.setSorter(ColumnViewerSorter.create(new ElementComparator(labelProvider)));
column.setVisible(false);
support.addColumn(column);
// $NON-NLS-1$
column = new Column("d%mvavg", Messages.ColumnDividendMovingAverageTotalRateOfReturn, SWT.RIGHT, 80);
labelProvider = new ReportingPeriodLabelProvider(SecurityPerformanceRecord::getTotalRateOfReturnDivMovingAverage, null, false);
// $NON-NLS-1$
column.setOptions(new ReportingPeriodColumnOptions(Messages.ColumnDividendMovingAverageTotalRateOfReturn + " {0}", options));
column.setGroupLabel(Messages.GroupLabelDividends);
column.setDescription(Messages.ColumnDividendMovingAverageTotalRateOfReturn_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 update.
@Override
void update() {
this.title.setText(getWidget().getLabel());
ReportingPeriod period = get(ReportingPeriodConfig.class).getReportingPeriod();
ExchangeRateTimeSeries series = get(ExchangeRateSeriesConfig.class).getSeries();
Optional<ExchangeRate> rate = series.lookupRate(period.getEndDate());
this.indicator.setText(series.getLabel() + ' ' + (rate.isPresent() ? Values.ExchangeRate.format(rate.get().getValue()) : '-'));
}
use of name.abuchen.portfolio.snapshot.ReportingPeriod in project portfolio by buchen.
the class ClientSecurityFilterTest method testThatAllSecuritiesHaveIdendicalPerformanceToClient.
@Test
public void testThatAllSecuritiesHaveIdendicalPerformanceToClient() {
Client filtered = new ClientSecurityFilter(securityEUR, securityUSD).filter(client);
assertThat(filtered.getAccounts(), hasSize(2));
assertThat(filtered.getPortfolios(), hasSize(1));
List<Exception> warnings = new ArrayList<>();
TestCurrencyConverter converter = new TestCurrencyConverter();
ReportingPeriod interval = new ReportingPeriod.FromXtoY(LocalDate.parse("2015-12-31"), LocalDate.parse("2017-01-31"));
PerformanceIndex all = PerformanceIndex.forClient(client, converter, interval, warnings);
assertThat(warnings, empty());
PerformanceIndex filteredAll = PerformanceIndex.forClient(filtered, converter, interval, warnings);
assertThat(warnings, empty());
assertThat(all.getFinalAccumulatedPercentage(), is(filteredAll.getFinalAccumulatedPercentage()));
assertThat(all.getDeltaPercentage(), is(filteredAll.getDeltaPercentage()));
}
use of name.abuchen.portfolio.snapshot.ReportingPeriod in project portfolio by buchen.
the class CurrencyTestCase method testClientPerformanceSnapshot.
@Test
public void testClientPerformanceSnapshot() {
ReportingPeriod period = new ReportingPeriod.FromXtoY(LocalDate.parse("2015-01-02"), LocalDate.parse("2015-01-14"));
ClientPerformanceSnapshot performance = new ClientPerformanceSnapshot(client, converter, period);
// calculating the totals is tested with #testClientSnapshot
assertThat(performance.getValue(CategoryType.INITIAL_VALUE), is(Money.of(CurrencyUnit.EUR, 4131_99)));
assertThat(performance.getValue(CategoryType.FINAL_VALUE), is(Money.of(CurrencyUnit.EUR, 4187_94)));
assertThat(performance.getAbsoluteDelta(), is(performance.getValue(CategoryType.FINAL_VALUE).subtract(performance.getValue(CategoryType.TRANSFERS)).subtract(performance.getValue(CategoryType.INITIAL_VALUE))));
assertThat(performance.getValue(CategoryType.CAPITAL_GAINS).add(performance.getValue(CategoryType.CURRENCY_GAINS)), is(performance.getValue(CategoryType.FINAL_VALUE).subtract(performance.getValue(CategoryType.INITIAL_VALUE))));
// compare with result calculated by Excel's XIRR function
assertThat(performance.getPerformanceIRR(), IsCloseTo.closeTo(0.505460984, 0.00000001));
}
use of name.abuchen.portfolio.snapshot.ReportingPeriod in project portfolio by buchen.
the class VolatilityTestCase method testVolatilityOfSharesHeldIsIdenticalToExcel.
@Test
public void testVolatilityOfSharesHeldIsIdenticalToExcel() throws IOException {
ReportingPeriod report = new ReportingPeriod.FromXtoY(LocalDate.parse("2014-01-31"), LocalDate.parse("2014-07-31"));
List<Exception> warnings = new ArrayList<>();
PerformanceIndex index = PerformanceIndex.forClient(client, converter, report, warnings);
assertThat(warnings, empty());
// excel
assertThat(index.getVolatility().getStandardDeviation(), closeTo(0.141568791460, 0.1e-10));
}
Aggregations