Corrections for XIRR implementation to achieve more accurate values
ClosedPublic

Authored by habacker on Nov 6 2018, 9:45 AM.

Details

Summary

In the Investment Report, the XIRR() function is used to calculate
the annual return. The previous implementation contains some errors
that have been corrected with this commit. In addition, if XIRR
cannot calculate the annual return to notify the user of this case,
an empty column is displayed in the investment report.

The basis for this fix is an update of the XIRR implementation from
the KOffice project [1], which brings the calculation up to date and
a further improvement from the libreoffice XIRR implementation [2] to
get more solutions using a two-pass approach. The class CashFlowList
has been moved to separate files to have a cleaner separation.

The obsolete and unused NPV function has been removed.

Tests for XIRR have been extended to check for recognized issues.

[1] https://github.com/KDE/koffice/blob/master/kcells/functions/financial.cpp
[2] https://raw.githubusercontent.com/LibreOffice/core/master/scaddins/source/analysis/financial.cxx

BUG:385993
FIXED-IN:4.8.3

Test Plan

compiled and tested on linux

Diff Detail

Repository
R261 KMyMoney
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
habacker requested review of this revision.Nov 6 2018, 9:45 AM
habacker created this revision.
habacker edited the summary of this revision. (Show Details)Nov 6 2018, 9:46 AM
habacker updated this revision to Diff 44952.Nov 6 2018, 9:51 AM
  • remove unrelated debug messages and setting of returninvestment
habacker updated this revision to Diff 45128.Nov 8 2018, 7:31 PM
habacker edited the summary of this revision. (Show Details)
  • rebased
  • update commit message
  • update doc of CashFlowList::XIRR()
This revision was not accepted when it landed; it landed in state Needs Review.Nov 9 2018, 12:44 PM
This revision was automatically updated to reflect the committed changes.
habacker reopened this revision.Nov 9 2018, 5:22 PM
habacker updated this revision to Diff 45186.Nov 9 2018, 5:22 PM
  • fix obs build
habacker updated this revision to Diff 45225.Nov 10 2018, 11:14 AM
  • gcc 4.8 compile fix
wojnilowicz accepted this revision.Nov 11 2018, 7:50 AM

It's a good move to move CashFlowList outside.

This revision is now accepted and ready to land.Nov 11 2018, 7:50 AM
This revision was automatically updated to reflect the committed changes.