-
Notifications
You must be signed in to change notification settings - Fork 625
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added adjusted internal rate of return
- Add new widget Adjusted IRR that allows to set benchmark to e.g. consumer price index to get inflation adjusted IRR.
- Loading branch information
Showing
8 changed files
with
68 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/dashboard/IRRAdjustedWidget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package name.abuchen.portfolio.ui.views.dashboard; | ||
|
||
import java.time.LocalDate; | ||
import java.util.function.Supplier; | ||
|
||
import name.abuchen.portfolio.model.Dashboard.Widget; | ||
import name.abuchen.portfolio.money.Values; | ||
import name.abuchen.portfolio.ui.views.dataseries.DataSeries; | ||
import name.abuchen.portfolio.util.Interval; | ||
|
||
public class IRRAdjustedWidget extends IndicatorWidget<Double> | ||
{ | ||
public IRRAdjustedWidget(Widget widget, DashboardData dashboardData) | ||
{ | ||
super(widget, dashboardData, false, null); | ||
this.setFormatter(Values.Percent2); | ||
|
||
addConfig(new DataSeriesConfig(this)); | ||
} | ||
|
||
@Override | ||
public Supplier<Double> getUpdateTask() | ||
{ | ||
return () -> { | ||
double irrBench = 0; | ||
Interval reportingPeriod = get(ReportingPeriodConfig.class).getReportingPeriod() | ||
.toInterval(LocalDate.now()); | ||
DataSeries dsBench = get(DataSeriesConfig.class, 1).getDataSeries(); | ||
if (dsBench != null) | ||
{ | ||
irrBench = getDashboardData().calculate(dsBench, reportingPeriod).getPerformanceIRR(); | ||
} | ||
|
||
double irr = getDashboardData().calculate(get(DataSeriesConfig.class).getDataSeries(), reportingPeriod) | ||
.getPerformanceIRR(); | ||
return (irrBench != -1) ? (1 + irr) / (1 + irrBench) - 1 : irr - irrBench; | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters