Reply to topic

Update quotes and currencies bug

gking
Registered Member
Posts
22
Karma
1

Update quotes and currencies bug

Sun Dec 06, 2020 3:39 am
I am running the latest app image (KMyMoney Version 5.1.0-4d16fb2) on Kubuntu 20.04. I gave up relying on KMM extracting stock and currency prices from online sources some time ago, and use Google finance to create a CSV file of my holdings, and parse the CSV with a custom script. It is a bit more cumbersome but has been very reliable and almost completely under my control. Recently when updating all stock and currency prices I get an error where KMM seems to be looking for a weird currency E000049 and of course not finding it. I have checked my stock configurations and they are all either Canadian or US dollar stocks. Everything seems to be OK in spite of the error message during updates. From the update log the issue looks like:
------------
Executing /home/wgking/get-stock-price.sh BATS:EFV...
Price found: '47.72' (47.72)
Date found: 'Fri Dec 4 2020'
Price for BATS:EFV updated (id E000064)
Executing /home/wgking/get-stock-price.sh CADE000049...
Unable to update price for CAD > E000049 (empty quote data)
Executing /home/wgking/get-stock-price.sh CADUSD...
Price found: '0.7822' (0.7822)
Date found: 'Sat Dec 5 2020'
Price for CAD > USD updated (id CAD USD)
Executing /home/wgking/get-stock-price.sh GCRRBDec2021...
-------------------
Details of the custom script and input source can be seen at https://pastebin.com/pbQmHfEX

Anyone have any idea why KMM is " Executing /home/wgking/get-stock-price.sh CADE000049..."? Could this be a bug?

Ideas welcome
User avatar ipwizard
KDE Developer
Posts
1261
Karma
6
OS
Looking at the pasted data, I find these two lines (among all the others)
Executing /home/wgking/get-stock-price.sh CADE000049...
Executing /home/wgking/get-stock-price.sh CADUSD...

It seems, that your URL for this is something like
file:///home/wgking/get-stock-price.sh %1%2

without a space between %1 and %2. That just for completeness. It also seems that it is working because it extracts the CAD to USD conversion without a problem.

Now on to the strange E000049: this is the (internal KMyMoney) id of an equity/security. It seems to be denominated in CAD. To find out, what it is, you can run the following command on your data-file.kmy. Replace this placeholder with the real path and name of your file.
Code: Select all
zgrep E000049 data-file.kmy | grep SECURITY
which should provide one line of information like this (I did it with E000001 and anonymized it a bit)
<SECURITY type="0" symbol="SYM" id="E000001" name="Name of SYM" rounding-method="0" trading-market="" saf="100" trading-currency="EUR" pp="4"/>

Maybe this will give you an idea of what you have changed recently. You can also look in the prices list and see if you find that internal ID in its column under Tools/Prices/Online Quotes. It would be interesting to learn about your findings.


ipwizard, proud to be a member of the KMyMoney forum since its beginning. :-D
openSuSE Leap 15.4 64bit, KF5
gking
Registered Member
Posts
22
Karma
1
Thank you for the quick reply and the debugging suggestions.

I ran the command against my .kmy file as follows:
[email protected]:~$ zgrep E000049 greg2017.kmy | grep SECURITY
<SECURITY saf="1000" id="E000049" name="TDB investment savings" symbol="TDB8150" type="1" rounding-method="0" trading-market="" pp="4" trading-currency="CAD">

This investment is a cash equivalent permanently valued at $10/unit and included to store cash that accumulates in the investment accounts. I have multiple investment accounts with TD and each has this investment. When I rerun the command to look for all similar investments I get:
[email protected]:~$ zgrep TDB8150 greg2017.kmy | grep SECURITY
<SECURITY saf="10000" id="E000043" name="TDB investment savings" symbol="TDB8150" type="1" rounding-method="0" trading-market="" pp="4" trading-currency="CAD">
<SECURITY saf="1000" id="E000045" name="TDB investment savings" symbol="TDB8150" type="1" rounding-method="0" trading-market="" pp="4" trading-currency="CAD">
<SECURITY saf="1000" id="E000049" name="TDB investment savings" symbol="TDB8150" type="1" rounding-method="0" trading-market="" pp="4" trading-currency="CAD">
<SECURITY saf="1000" id="E000081" name="TDB Investment Savings" symbol="TDB8150" type="2" rounding-method="0" trading-market="" pp="4" trading-currency="CAD">
<SECURITY saf="100000" id="E000096" name="tdb Investment savings" symbol="TDB8150" type="1" rounding-method="7" trading-market="FUND" pp="4" trading-currency="CAD">

but only the one with id="E000049" is having a problem.

I noticed that they were not all setup identically, so I went into each investment and made them all identical (Mutual fund, blank trading market, trading symbol=identification number =TDB8150), and full name the same. Now I get:
[email protected]:~$ zgrep TDB8150 greg2017.kmy | grep SECURITY
<SECURITY pp="4" rounding-method="7" name="TDB investment savings" trading-market="" symbol="TDB8150" saf="10000" id="E000043" trading-currency="CAD" type="1">
<SECURITY pp="4" rounding-method="7" name="TDB investment savings" trading-market="" symbol="TDB8150" saf="1000" id="E000045" trading-currency="CAD" type="1">
<SECURITY pp="4" rounding-method="7" name="TDB investment savings" trading-market="" symbol="TDB8150" saf="1000" id="E000049" trading-currency="CAD" type="1">
<SECURITY pp="4" rounding-method="7" name="TDB Investment Savings" trading-market="" symbol="TDB8150" saf="1000" id="E000081" trading-currency="CAD" type="1">
<SECURITY pp="4" rounding-method="7" name="TDB Investment savings" trading-market="" symbol="TDB8150" saf="100000" id="E000096" trading-currency="CAD" type="1">

When I run the stock and currency update I still get the same error.
Executing /home/wgking/get-stock-price.sh BATS:EFV...
Price found: '47.72' (47.72)
Date found: 'Fri Dec 4 2020'
Price for BATS:EFV updated (id E000064)
Executing /home/wgking/get-stock-price.sh CADE000049...
Unable to update price for CAD > E000049 (empty quote data)
Executing /home/wgking/get-stock-price.sh CADUSD...
Price found: '0.7825' (0.7825)
Date found: 'Sun Dec 6 2020'
Price for CAD > USD updated (id CAD USD)

I have also replaced the "Online Quotes->KMyMoney Currency" with the same script I am using for stock prices since I only need Canada-USA exchange rates. The popup I get during updates seems to imply KMM is trying to do a currency conversion but all those holdings are in CAD. As a workaround I could disable price updates for these investments since they are all fixed at $10 anyway, but it should work and it used to work a while back, and it still works for 3 out of 4...

All ideas welcome.

Greg
gking
Registered Member
Posts
22
Karma
1
I now think the problem may be a corrupt database. It seemed to start on Nov 7, 2020 and has been happening since. I usually update stock prices once per week, but starting Nov 7 I am seeing a strange currency conversion from CAD to investment TDB8150 which makes no sense. Plus the amount is suspicious it looks like it is derived from the investment name. (81500.10 ). A screen-shot of the strange entry is at:
https://drive.google.com/file/d/1w-R422 ... sp=sharing

Ideas on how to fix the database would be greatly appreciated.
gking
Registered Member
Posts
22
Karma
1

Re: Update quotes and currencies bug

Tue Dec 08, 2020 12:49 am
I have been poking around to see if I can fix my KMM database. I found the source of the invalid currency pair:
<PRICEPAIR to="E000049" from="CAD">
<PRICE price="1/10" date="2020-10-12" source="User"/>
<PRICE price="815001/10" date="2020-11-07" source="KMyMoney Currency"/>
<PRICE price="815001/10" date="2020-11-14" source="KMyMoney Currency"/>
<PRICE price="815001/10" date="2020-11-21" source="KMyMoney Currency"/>
<PRICE price="815001/10" date="2020-11-28" source="KMyMoney Currency"/>
<PRICE price="815081508150815001/10" date="2020-12-05" source="KMyMoney Currency"/>
<PRICE price="8150815001/10" date="2020-12-06" source="KMyMoney Currency"/>
<PRICE price="815001/10" date="2020-12-07" source="KMyMoney Currency"/>
</PRICEPAIR>
<PRICEPAIR to="USD" from="CAD">
<PRICE price="1/1" date="2017-11-01" source="User"/>

It is the only one of this type:
[email protected]:~$ zgrep 'PRICEPAIR to=\"E0000' greg2017.kmy
<PRICEPAIR to="E000049" from="CAD">
[email protected]:~$ zgrep 'PRICEPAIR to=\"CAD' greg2017.kmy
<PRICEPAIR to="CAD" from="E000001">
<PRICEPAIR to="CAD" from="E000002">
..... lots of these

I don't see E000049 listed in the currencies in KMM. Since the database seems to be an XML file I tried to delete those incorrect entries with the following:
zcat greg2017.kmy > greg2017.txt
nano greg2017.txt (delete the PRICEPAIR block for E000049)
zip test.kmy greg2017.txt

KMM refuses to open the resulting file with message
"Could not read your data source. Please check the KMyMoney settings that the necessary plugins is enabled"

I am over my head here not having delved deeply into the XML file structure. I also tried redoing (deleting + re-entering) the 2020-10-12 transaction that seemed to create this bogus entry to no avail.

Still looking for a solution...
gking
Registered Member
Posts
22
Karma
1
FIXED! (I think)

I tried opening the .txt file I edited and KMM opened it and everything seems to be correct. I updated all stocks and currencies and did not get the error re E000049. I saved it as a new .kmy file and all seems to be good. Hopefully my hack did not break anything.
User avatar ipwizard
KDE Developer
Posts
1261
Karma
6
OS
Since you only removed the price entries, it would only do harm, if these are used somewhere. So it seems you are good to go.

Regarding the compression: there is a significant difference between gzip and zip. They are just two different things (formats). KMyMoney only supports the gzip format. zcat is used to uncompress gzip formatted files. But in the end, you found out that KMyMoney also reads the plain text format. By the way, all this is documented in the KMyMoney manual. KMyMoney reads uncompressed files and stores them compressed the next time you safe them. To store uncompressed one simply needs to use the .xml extension.


ipwizard, proud to be a member of the KMyMoney forum since its beginning. :-D
openSuSE Leap 15.4 64bit, KF5
gking
Registered Member
Posts
22
Karma
1
Thanks for the info and the reassurance that I did not break anything. The entry I deleted is an obviously bogus currency pair. Any Idea how it got into the database in the fist place? I have been doing the same types of transactions for years so I don't think it was "user error" and hopefully it will not happen again.

Thanks for your help in getting me on the path to resolving the issue.
gcash
Registered Member
Posts
96
Karma
0
OS
I have been getting this error for some time now when trying to update the prices. Is it part of the same bug ?
Code: Select all
Failed to retrieve a quote for VWENX from New Quote Source. Press No to remove the online price source from this security permanently, Yes to continue updating this security during future price updates or Cancel to stop the current update operation.
catherine
Registered Member
Posts
3
Karma
0
I've had this bug for a while with one entry that always failed, but yesterday I ended up with a further 3 bogus entries and I finally know what I did that added these entries and can reproduce it. I was in the Brokerage account and edited an entry. I was presented with an Exchange Rate/Price editor window, which has a tickbox for Update price history. If I let it do that, the additional incorrect item is added to the List of known equities. Therefore the stock price entry must be wrong from here.

I've copied gking's method and fixed mine as well - thank you!
User avatar ipwizard
KDE Developer
Posts
1261
Karma
6
OS
catherine wrote:I've had this bug for a while with one entry that always failed, but yesterday I ended up with a further 3 bogus entries and I finally know what I did that added these entries and can reproduce it. I was in the Brokerage account and edited an entry. I was presented with an Exchange Rate/Price editor window, which has a tickbox for Update price history. If I let it do that, the additional incorrect item is added to the List of known equities. Therefore the stock price entry must be wrong from here.

Great, now we know how to reproduce the problem - almost. A few tiny things are missing, but I am sure you can help out:
  • Which type of transaction did you edit in the brokerage account? An investment transaction or a normal transaction (transfer to another account?) ?
  • What did you change, i.e. which field(s)?
  • Which currencies are involved? The base currency, the currency of the brokerage account and the trading currency of the security are of interest.


ipwizard, proud to be a member of the KMyMoney forum since its beginning. :-D
openSuSE Leap 15.4 64bit, KF5
catherine
Registered Member
Posts
3
Karma
0
ipwizard wrote:
catherine wrote:I've had this bug for a while with one entry that always failed, but yesterday I ended up with a further 3 bogus entries and I finally know what I did that added these entries and can reproduce it. I was in the Brokerage account and edited an entry. I was presented with an Exchange Rate/Price editor window, which has a tickbox for Update price history. If I let it do that, the additional incorrect item is added to the List of known equities. Therefore the stock price entry must be wrong from here.

Great, now we know how to reproduce the problem - almost. A few tiny things are missing, but I am sure you can help out:
  • Which type of transaction did you edit in the brokerage account? An investment transaction or a normal transaction (transfer to another account?) ?
  • What did you change, i.e. which field(s)?
  • Which currencies are involved? The base currency, the currency of the brokerage account and the trading currency of the security are of interest.


- editing an investment transaction from the brokerage account. It's a Buy.
- I don't have to change anything, just Edit and then Enter, to get the popup with the Update price history checkbox.
- Option displayed is Convert "Currency GBP" to "Stock GB00BXXXXXXX". I then have the Update Price history checkbox. Upon entering this transaction. a new entry has appeared in Update Stock and currency prices, with
  • ID "GBP > E000012",
  • Name "GBP units in E000012",
  • Price "GB00BXXXXXXX 0.4566"
  • Date is today, although the edited transaction was 13th Jan
  • Internal ID "GBP E000012"
  • Source "KMyMoney Currency"

Dividend did not show this behaviour, but Sell did.
- Currencies. All GBP.
User avatar ipwizard
KDE Developer
Posts
1261
Karma
6
OS
Thanks for the detailed info. Doing it on a Buy transaction is the key to duplicate the problem. I first did it on a Sell transaction. Now on to some more debugging on my end.


ipwizard, proud to be a member of the KMyMoney forum since its beginning. :-D
openSuSE Leap 15.4 64bit, KF5
ravisghosh
Registered Member
Posts
5
Karma
0
catherine wrote:I've had this bug for a while with one entry that always failed, but yesterday I ended up with a further 3 bogus entries and I finally know what I did that added these entries and can reproduce it. I was in the Brokerage account and edited an entry. I was presented with an Exchange Rate/Price editor window, which has a tickbox for Update price history. If I let it do that, the additional incorrect item is added to the List of known equities. Therefore the stock price entry must be wrong from here.

I've copied gking's method and fixed mine as well - thank you!


I second that. This is certainly the cause of the issue. However, to open .kmy file as text and edit it sounds little scary as it might potentially mess other things.
ravisghosh
Registered Member
Posts
5
Karma
0
Here is aother solution.

Tools > Update Stock and Currency Prices > Sort by ID >

Find the entries that are causing errors. In the price column of the entry, you would find the name of the security. Note it down.

Go to Tools > Prices > Click "Show all stored prices" > Sort by Source > Scroll down to "KMyMoney Currency"

You'll find many entries of the previously noted down securities with price of 0. Delete these entries. Also, delete the price entries created by "User" even though it might have price > 0.

Tools > Update Stock and Currency Prices > Update All > Voila! No error :)

If it didn't work, go to Prices and sort by "Commodity". Go to the security ou had noted previously and look for the prices from source "KMMoney Currency" or "User". Delete these. Sometimes, sorting by Source doesn't show all entries and you will keep getting the error.

 
Reply to topic

Bookmarks



Who is online

Registered users: acrux, Bing [Bot], claydoh, cvanaret, gerbilfat, Google [Bot], joecoool, koffeinfriedhof, Sogou [Bot], Stephen Leibowitz