Bug 396301 - Investment Performance by Account YTD Return on Investment result different between version 4.8 and 5.01
Summary: Investment Performance by Account YTD Return on Investment result different b...
Status: REPORTED
Alias: None
Product: kmymoney
Classification: Applications
Component: reports (show other bugs)
Version: 5.1.2
Platform: Mint (Ubuntu based) Linux
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-08 02:36 UTC by Jon
Modified: 2022-12-27 00:03 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jon 2018-07-08 02:36:38 UTC
I have been using KMyMoney version 4.8 for several years in Linux Mint 18.3.  I upgraded a few days ago to Linux Mint 19 and installed KMyMoney 5.0.1 using the Software Manager.  When I ran the Investment by Account YTD report I see that version 5.0.1 provides different values for Return on Investment than those provided by version 4.8. I believe (but am not certain) that version 4.8 provides the correct results.

For example, I have a mutual fund bond account that pays a monthly dividend that is reinvested to buy additional shares.  There have been no Buy or Sell activities this year.  Version 4.8 calculates the difference between the Beginning Balance and Ending Balance and divides the result by the beginning balance then multiplies the result by 100 to convert it into the Return on Investment percentage.  Version 5.0.1 gives a different answer that I have been able to duplicate by subtracting the Beginning Balance AND the Dividends Reinvested from the Ending Balance and dividing a result that again is multiplied by 100 to convert to a percentage.  Because the Dividends Reinvested were used to purchase new shares that are included in the Ending Balance I see no reason to subtract the Dividends Reinvested value from the Ending Balance when calculating Return on Investment.

I have another mutual fund account from which we take monthly dividends in cash (no reinvestment).  There has been no Buy or Sell activity this year.  Both version 4.8 and 5.0.1 calculate the same (that I believe correct) Return on Investment percentage by adding the Dividends Paid Out to the Ending Balance, subtracting the Beginning Balance and then dividing the result by the Beginning Balance and converting to a percentage.

I have a third mutual fund that has quarterly Reinvested Dividends and Buy activity but no Sell activity this year.  Version 4.8 calculates Return on Investment for this fund by subtracting both the Beginning Balance and Buy Value from the Ending Balance, then dividing the result by the sum of the Beginning Balance and Buy Value.  The Dividends Reinvested amount is not a part of the calculation.  Version 5.0.1 comes up with a lower Return on Investment that I have been unable to duplicate in any way.

I have a fourth mutual fund that has quarterly Reinvested Dividends and Sell activity but no Buy activity this year.  Version 4.8 calculates Return on Investment for this fund by subtracting the Sell Value from the Beginning Balance and then subtracting the result from the Ending Balance.  Dividing this result by the Beginning Balance minus the Sell Value gives the Return on Investment.  The Dividends Reinvested amount is not a part of the calculation.  Version 5.0.1 comes up with a lower Return on Investment that I have been unable to duplicate in any way.

The Annualized Return percentages for all of my individual investments are the same for both version 4.8 and 5.0.1 and also match what I calculate using the Excel XIRR function.  I'm not sure about the new Annualized Return Account totals  in version 5.0.1 as I haven't tried to match them in Excel as yet.

Thank you in advance for any assistance in resolving the differences between version 4.8 and 5.0.1.

Jon
Comment 1 Justin Zobel 2022-11-26 00:13:44 UTC
Thank you for reporting this issue in KDE software. As it has been a while since this issue was reported, can we please ask you to see if you can reproduce the issue with a recent software version?

If you can reproduce the issue, please change the status to "REPORTED" when replying. Thank you!
Comment 2 Jon 2022-12-03 00:26:13 UTC
I am currently using KmyMoney version 5.1.2 running on Linux Mint version 21.  The Investment Performance By Account report continues to miscalculate the Return on Investment for those investments that have some or all Dividends Reinvested.  The report correctly calculates Return on Investment for all other situations, including when all Dividends are Paid Out.

Using the column headings on the report, I believe that Return on Investment should be calculated as follows:
(Ending Balance + Dividends Paid Out + Sell Value) – (Starting Balance + Buy Value) = Return

The % Return is then calculated by:
100 * Return / (Starting Balance + Buy Value)

Dividends Reinvested are not an item included in the return calculation because the value of the shares from the reinvestment is already part of the Ending Balance.

I created a KmyMoney file with only 4 transactions as a test.  The share price for all transactions is set to $100 so that price changes could be ruled out of the issue.

For the Dividends Paid Out situation:
Starting Balance transaction – 12/31/21 buy 8 shares at $100/share = $800
Buy Value transaction – 3/22/22 buy 4 shares at $100/share = $400
Dividends Paid Out transaction – 6/30/22 = $150
Sell Value transaction – 12/2/22 sell 10 shares at $100/share = $1,000
Ending Balance = $200

($200 + $150 + $1,000) - ($800 + $400) = $150 Return

$150 / ($800 + $400) = 0.125 * 100 = 12.5%   The The Investment Performance By Account report agrees with this result.

For the Dividends Reinvested situation:
Starting Balance transaction – 12/31/21 buy 8 shares at $100/share = $800
Buy Value transaction – 3/22/22 buy 4 shares at $100/share = $400
Dividends Reinvested transaction – 6/30/22 = 1.5 shares added at $100/share
Sell Value transaction – 12/2/22 sell 10 shares at $100/share = $1,000
Ending Balance = $350

($350 + $0 + $1,000) - ($800 + $400) = $150 Return

$150 / ($800 + $400) = 0.125 * 100 = 12.5%  For this case the The Investment Performance By Account report shows an incorrect 0% return and strangely, a 15.51% Annualized Return.   How can a zero return also have a greater than zero annualized return?

I only invest in mutual funds so do not know whether the calculation is different for individual stocks or bonds.  When a mutual fund does a dividend reinvestment they simply add the number of shares that match the dividend value at the current price.  This is not a Buy transaction.
Comment 3 Jack 2022-12-03 00:53:38 UTC
I have not yet looked into your examples in detail, but I think you over-complicate the calculations.   Starting and ending balances are irrelevant to return for a single investment.  (It would be the same ROI no matter which account it took place in.)  Take a look at https://www.investopedia.com/articles/basics/10/guide-to-calculating-roi.asp.  (I think mutual funds can use the same calculations as stocks and bonds.)  
First work through it without any reinvestment transactions, nut I agree that those transactions can be ignored, since they just mean you are selling more shares than you purchased.  The critical values are total purchase cost and total sale value.  I won't copy/paste the formula from that link, but after you review it, let us know if you still think KMM is making incorrect calculations.
Annualized returns can be even more complicated if there is not a single purchase and single sale.
Separately, your example shows two purchases of 8 and 4, a dividend reinvestment of 1.5 shares, but a sale of only 10 shares.  What happened to the other 3.5 shares?
Comment 4 Jon 2022-12-07 19:23:22 UTC
To answer you question, the 3.5 shares not sold are the $350 in the Ending Balance.

I reviewed the information on ROI calculation in the Investopedia link you provided.  As an investor, I have used this calculation many times.  KMyMoney does not have the functionality to correctly make this ROI calculation.  KmyMoney Handbook has the following statement about ROI in the Investment section:

“Unimplemented Features
There are some features that are normally associated with investments which are not yet implemented in KMyMoney. These include, but are not limited to derivatives, options, and futures. In addition, when you sell a security, KMyMoney does not know which specific shares you are selling, i.e., the oldest or the most recently purchased, so it cannot calculate return on investment. Finally, it has no direct knowledge about any country's specific tax reporting requirements, but these can usually be handled by marking as Tax related all the categories you use for transactions which might have tax consequences.”

After reading this, I was curious how KMyMoney was able to do the ROI calculation for the Investment Capital Gains reports.  I created another  KMyMoney file with one investment account and put in several Buy and Sell transactions using made up numbers to see if I could figure out how the program was determining the buy value for each time shares were sold.  It appears that the program is using a First In/First Out method (first shares bought are the first shares sold).  Lacking the ability to identify the specific shares sold, this a reasonable but not accurate way to estimate capital gains.  The gain is accurate only for the situation where the report date range includes all of the transaction dates and also all shares have been sold.

The KMyMoney file I created included only Buy transactions for 2021.  For 2022 I included one Buy transactions and two Sell transactions that sold all shares.  Total Buy value for 2021 was $1295 and another $210 for 2022, for a grand total of $1505.  The total Sell value was $1340.  The ROI calculation is therefore ($1340 – $1505) / $1505 = a 10.96% loss.  The Capital Gains report in KMyMoney matches this result.  When I ran the Investment Performance report with a date range of All Dates, I see Beginning Balance $0, Buy Value $1505, Sell Value $1340, Ending Balance $0 and ROI of 10.96% loss, matching the Capital Gains report.  However, a different result happens when I use the default report date range of Year to Date.  In that case I see Beginning Balance of $1500, Buy Value $210, Sell Value $1340,  Ending Balance $0 and ROI of 21.64% loss.  Since all shares that were bought were sold, this is obviously an incorrect result.  The problem is that the shares bought in 2021 had an increase in share price by the end of the year bringing the ending value of the shares to $1500. The Beginning Balance for 2022 should have been the ending Buy Value for 2021 of $1295, not the Investment Value based on the year end share price.

There are two types of investment gains.  When shares are sold we have “realized” gains as above.  If not all shares are sold we also have “unrealized” gains.  Unrealized gains are calculated as the increase or decrease in share value based on the current share price minus the buy value of the shares.  Unrealized gains vary from day to day as share prices change due to market activity.  Unrealized gains are part of the performance of an investment.  The Investment Performance report does not use the unrealized gain value as the Ending Balance.  Instead, it uses the full value of the shares at the ending price.  This is wrong. The report calculates the ROI by adding the Ending Balance to the Sell Value.  The Ending Balance needs to be the unrealized gain amount, not the ending shares value.  A better title for Ending Balance would be Unrealized Gain/Loss.
Comment 5 Bug Janitor Service 2022-12-22 05:19:54 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 6 Jon 2022-12-27 00:03:16 UTC
Thanks for advising that I neglected to mark my previous comment (Comment 4) as “Reported”.  Please refer to that comment for other details if necessary.

The first issue with the Investment Performance reports is that the Return on Investment is only calculated correctly when the Date Range selected is either All Dates or a Date Range that begins with or earlier than the first Buy transaction.  All other Date Ranges calculate an incorrect Return on Investment.  The reason for the incorrect result is that the Starting Balance for these other Date Ranges is calculated by KMyMoney as the number of shares held on the report’s beginning date multiplied by the share price on that date.  The correct value for the Starting Balance should be the original Buy Value of those shares, not the Buy Value +/- any gain/loss in share price as of the beginning date.

The second issue with the Investment Performance reports is that the Dividends Reinvestment value is being calculated as if it were a Buy Value, which results in an incorrect Return on Investment.  Buy Value is the amount of cash that an investor uses to purchase new shares.  Shares added to the investor’s account by the mutual fund in a Dividend or Capital Gain distribution are not a purchase made by the shareholder.  The value of shares added in a reinvestment is correctly accounted for as a part of the total number the shareholder owns.  The Dividends Reinvested value should not be used in any additional way in calculating Return on Investment.

Dividends Paid Out are cash in the investor’s hand and this value is correctly calculated by KMyMoney as a gain in the Investment Performance reports.