This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Rounding errors when updating account

Tags: None
(comma "," separated)
zebulon
Registered Member
Posts
417
Karma
2
OS
I have a 401k investment account that I can update directly. Yet, I end up doing it manually through OFX import, because the direct update gives different results. Every month, a fixed amount is invested in a number of funds. I have defined these funds to use "Total for all shares" in the Price Entry section of the investment setup. The share prices should be equal to the invested amounts divided by the respective number of shares, which is nearly always a number with as many decimals as KMM has been set to store. The problem is that with direct update, a fixed share prices (two decimals) is obtained, and the total amount is not right (more than two decimals). Is this the fault of the financial institution, or can it be fixed?
john_hudson
Registered Member
Posts
549
Karma
2
OS
Firstly, are you sure that the figures you obtain directly only have two decimal places?

Secondly, how many decimal places are set in Settings>Configure KMyMoney>Global>Price precision?

Thirdly, does changing the setting have any effect on the results?


John Hudson, proud to be a member of KDE forums since 2008-Oct.
zebulon
Registered Member
Posts
417
Karma
2
OS
john_hudson wrote:Firstly, are you sure that the figures you obtain directly only have two decimal places?
Yes. I have the following operation (buy shares) if imported manually:
Code: Select all
Q=27.288 P=$10.459909 V=$285.430000
where Q is quantity, P price, V value. I am editing the transaction to see all digits, because the ledger shows price per share at full precision, while value is always two digits. Now, if I update the account, I get
Code: Select all
Q=27.288 P=$10.460000 V=$285.432480
There are three numbers with one dependency here. It is obvious that the number of shares is always an independent variable; the second one is the total value with OFX import, but it's price per share with automatic update.
john hudson wrote:Secondly, how many decimal places are set in Settings>Configure KMyMoney>Global>Price precision?
Six digits.
john hudson wrote:Thirdly, does changing the setting have any effect on the results?
Yes. As expected, V=$285.4325 if I reduce the number of digits to 4. All else remains equal.

The direct update does not follow the definition of the investment, according to which "total for all shares" should have been used. Actually, I am surprised that is even an option.
zebulon
Registered Member
Posts
417
Karma
2
OS
zebulon wrote:It is obvious that the number of shares is always an independent variable
Well, maybe it is not. The investment has been defined in 1/1000 both in KMM and by the financial institution; so, three digits is fixed precision for Q. The invested amount V is definitely fixed i.e. no roundoff is allowed. You divide V by the price per share and get the quantity. The quantity is then rounded to three decimals and becomes fixed. This leaves only the price to absorb any round-off.
john_hudson
Registered Member
Posts
549
Karma
2
OS
The first result of Q × P = 285.4299968 but this is rounded to six decimal places.
In the second calculation P is rounded to two decimal places so that Q × P = 285.43248. So in both cases the outputs are correct. The issue is the rounding of P to two decimal places for the second calculation.

This may be a bug/feature of KMyMoney but it may be worth increasing the price precision to 7 to see if this makes any difference.


John Hudson, proud to be a member of KDE forums since 2008-Oct.
zebulon
Registered Member
Posts
417
Karma
2
OS
john_hudson wrote:This may be a bug/feature of KMyMoney but it may be worth increasing the price precision to 7 to see if this makes any difference.
Thanks, John, for your feedback. I'm sure it will react as you predict: method 1 will give 285.4299968, while method 2 will come up with the exact same numbers as before, based on a two-digit price (additional digits beyond the fifth decimal are zero).
john_hudson wrote:So in both cases the outputs are correct.
Not to me. The amount of the transfer was $285.43 exactly. The actual price per share of the transaction was not $10.46 but slightly less. So, I think you cannot simultaneously define "price" as the stock market quote upon which the transaction is based and link it to the value of the transaction. That link requires an adjusted (actual) price. It would be interesting to hear what the developers think.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]