use of name.abuchen.portfolio.snapshot.PerformanceIndex in project portfolio by buchen.
the class PerformanceHeatmapWidget method fillTable.
private void fillTable() {
// fill the table lines according to the supplied period
// calculate the performance with a temporary reporting period
// calculate the color interpolated between red and green with yellow as
// the median
Interval interval = get(ReportingPeriodConfig.class).getReportingPeriod().toInterval();
DoubleFunction<Color> coloring = buildColorFunction();
addHeaderRow();
DataSeries dataSeries = get(DataSeriesConfig.class).getDataSeries();
// adapt interval to include the first and last month fully
Interval calcInterval = Interval.of(interval.getStart().getDayOfMonth() == interval.getStart().lengthOfMonth() ? interval.getStart() : interval.getStart().withDayOfMonth(1).minusDays(1), interval.getEnd().withDayOfMonth(interval.getEnd().lengthOfMonth()));
PerformanceIndex performanceIndex = getDashboardData().calculate(dataSeries, new ReportingPeriod.FromXtoY(calcInterval));
Interval actualInterval = performanceIndex.getActualInterval();
for (Integer year : actualInterval.iterYears()) {
// year
Cell cell = new Cell(table, () -> {
int numColumns = getDashboardData().getDashboard().getColumns().size();
return numColumns > 2 ? String.valueOf(year % 100) : String.valueOf(year);
});
GridDataFactory.fillDefaults().grab(true, false).applyTo(cell);
// monthly data
for (LocalDate month = LocalDate.of(year, 1, 1); month.getYear() == year; month = month.plusMonths(1)) {
if (actualInterval.contains(month)) {
cell = createCell(performanceIndex, month, coloring);
InfoToolTip.attach(cell, Messages.PerformanceHeatmapToolTip);
} else {
// $NON-NLS-1$
cell = new Cell(table, () -> "");
}
GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.FILL).applyTo(cell);
}
}
table.layout(true);
}
use of name.abuchen.portfolio.snapshot.PerformanceIndex in project portfolio by buchen.
the class PerformanceChartSeriesBuilder method addClient.
private void addClient(DataSeries series, PerformanceIndex clientIndex, Aggregation.Period aggregationPeriod) {
PerformanceIndex index = aggregationPeriod != null ? Aggregation.aggregate(clientIndex, aggregationPeriod) : clientIndex;
switch((ClientDataSeries) series.getInstance()) {
case TOTALS:
ILineSeries lineSeries = getChart().addDateSeries(index.getDates(), index.getAccumulatedPercentage(), series.getLabel());
configure(series, lineSeries);
break;
case DELTA_PERCENTAGE:
String aggreagtionPeriodLabel = aggregationPeriod != null ? aggregationPeriod.toString() : Messages.LabelAggregationDaily;
IBarSeries barSeries = getChart().addDateBarSeries(index.getDates(), index.getDeltaPercentage(), aggreagtionPeriodLabel);
// update label, e.g. 'daily' to 'weekly'
series.setLabel(aggreagtionPeriodLabel);
configure(series, barSeries);
break;
default:
break;
}
}
use of name.abuchen.portfolio.snapshot.PerformanceIndex in project portfolio by buchen.
the class StatementOfAssetsSeriesBuilder method build.
public void build(DataSeries series, ReportingPeriod reportingPeriod) {
PerformanceIndex index = getCache().lookup(series, reportingPeriod);
if (series.getType() == DataSeries.Type.CLIENT) {
addClient(series, index);
} else {
ILineSeries lineSeries = getChart().addDateSeries(index.getDates(), toDouble(index.getTotals(), Values.Amount.divider()), series.getLabel());
configure(series, lineSeries);
}
}
Aggregations