Reply to topic

Currency Quotes

alainpetit
Registered Member
Posts
10
Karma
0

Re: Currency Quotes

Sat Nov 04, 2017 10:44 am
ipwizard wrote:Well, bad news: the source is tied to "Yahoo Currency" since a long time. In case someone is interested: here is the change. We see, that this was introduced 12 years ago and worked ever since. While looking further into the source code of KMyMoney, I noticed, that one cannot change the quote source for currency exchange rates. That is tied to the name Yahoo Currency (see above code change).

What this comes down to:
  • KMyMoney only supports a single price source for currency exchange rates at the moment and it must be named Yahoo Currency.
  • As a workaround, simply modify the values of the Yahoo Currency entry but do not change the name. Once that is changed, the original version will be recreated by KMyMoney.
I verified, that the following configuration is working (in KMyMoney master):
Code: Select all
URL : https://finance.google.com/finance?q=%1%2
Identifier: "name"\s+content="([^"]+)"
Price : "price"\s+content="((\d+|\d{1,3}(?:[,]\d{3})).\d+)
Date : "quoteTime"\s+content="(\d{4}-\d{2}-\d{2})T
Date Format : %y-%m-%d
SKIP HTML Stripping : CHECKED !!


Ohhh yea I see the hard-coded line in the code now, I had the same reaction ... download the cpp source and perform "find . -type f -exec grep -H 'Yahoo Currency' {} \;" on the source code. Thanks guys for fixing the regex, I'm not fluent with it

Although All this workaround thread should fix 99% of currency, but it aint fixing my problem with ETH (Ethereum crypto Currency), which was working fine in Yahoo Currency ... lol Am I the only one with this problem here ;)

@ipwizard ... I have an idea : the code snippet that you just quoted is from the addprice of the update dialog, right. Not being familiar with the execution of this, is this called at 1) the time of the addition of the currency in the system or 2) the execution of the updateprice ?

If 1) then, the source should be saved in some sort of setting or file (kmymoneyrc ??) and can be manually change (hack). or 2) cannot be change but get assigned "Yahoo Currency" every run of update price.

Alternative solution ... Create a webpage that will kind of do the fol logic at the html level :
Code: Select all
   if quotePair1 == "ETH" OR "LTC" OR "... whatever cryptocurrency not supported by Google"
       source= "https://www.quadrigacx.com/market/quotePair1/quotePair2"
   else
       source= "https://finance.google.com/finance?q=quotePair1quotePair2"


Would that be feasible ? ... I know it sound like an "only me" kind of problem ... but it's worth the shot to ask for advices here
User avatar ipwizard
KDE Developer
Posts
455
Karma
1
OS

Re: Currency Quotes

Sun Nov 05, 2017 7:17 am
alainpetit wrote:@ipwizard ... I have an idea : the code snippet that you just quoted is from the addprice of the update dialog, right. Not being familiar with the execution of this, is this called at 1) the time of the addition of the currency in the system or 2) the execution of the updateprice ?

If 1) then, the source should be saved in some sort of setting or file (kmymoneyrc ??) and can be manually change (hack). or 2) cannot be change but get assigned "Yahoo Currency" every run of update price.

Unfortunately, the answer is 2)

alainpetit wrote:Alternative solution ... Create a webpage that will kind of do the fol logic at the html level :
Code: Select all
   if quotePair1 == "ETH" OR "LTC" OR "... whatever cryptocurrency not supported by Google"
       source= "https://www.quadrigacx.com/market/quotePair1/quotePair2"
   else
       source= "https://finance.google.com/finance?q=quotePair1quotePair2"


Would that be feasible ? ... I know it sound like an "only me" kind of problem ... but it's worth the shot to ask for advices here

To some extent it might be possible to intercept the request on HTTP level using a reverse proxy of some sort and check the URL for specific currencies. I am not familiar with HTML mechanisms at that point. Javascript btw. is not available at that point.

The right way to fix it is to add a possibility to choose the quote source for currency conversions (maybe having one as a default to begin with).


ipwizard, proud to be a member of the KMyMoney forum since its beginning. :-D
openSuSE Leap 42.2 64bit, KF5
alainpetit
Registered Member
Posts
10
Karma
0

Re: Currency Quotes

Sun Nov 05, 2017 3:03 pm
ipwizard wrote:
alainpetit wrote:@ipwizard ... I have an idea : the code snippet that you just quoted is from the addprice of the update dialog, right. Not being familiar with the execution of this, is this called at 1) the time of the addition of the currency in the system or 2) the execution of the updateprice ?

If 1) then, the source should be saved in some sort of setting or file (kmymoneyrc ??) and can be manually change (hack). or 2) cannot be change but get assigned "Yahoo Currency" every run of update price.

Unfortunately, the answer is 2)

Hum .... I'm about to start thinking cloning a copy of the source code of Kmymoney for myself and add something in the line of :

Code: Select all
   if((pair.first == "ETH") || (pair.second == "ETH") || (pair.first == "BTC") || (pair.second == "BTC"){
           item->setText(SOURCE_COL, "QuadrigaCX Currency");  // Assuming that this will be added
   else{
           item->setText(SOURCE_COL, "Yahoo Currency");  // This string value should not be localized
   }
User avatar Steve R.
Registered Member
Posts
13
Karma
0

Re: Currency Quotes

Mon Nov 06, 2017 1:42 am
I attempted to apply the solution posted by jsalatas ipwizard on November 3, 2017. It failed, sort-of, but read on. Additionally I have a concern. This discussion concerns "Currency Quotes" and I do not seek any currency quotes. For me the concern is stock prices that are not downloading.
I went ahead, as an experiment, an applied the solution posted by jsalatas to "Yahoo" (NOT Yahoo Currency). It gets complicated.
I pasted this into "Yahoo" and received the following error message:
Code: Select all
URL : https://finance.google.com/finance?q=%1%2
"Malformed URL .
Unable to update price for BP (empty quote data)"

--------------------------------------------------------------------------------------------------------------
As an experiment I changed the code to:
Code: Select all
URL : https://finance.google.com/finance?q=%1

All stocks except for three now updated. At this time, I have no explanation for why three stocks did not get updated.
I checked the stock symbols on Yahoo and they appear correct.

11/5/2017 - Now that the market has opened and there are current stock prices available, I tried again and three stock prices failed to update.
The three stocks that fail to update their stock price are: RDS-A, RDS-B, and SON

Changing the RDS symbols to RDS.A and RDS.B resolved retrieving those quotes. SON still not updating.

Error message received for SON:
Fetching URL https://finance.google.com/finance?q=SON...
Unable to update price for SON (no price or no date)
Yet the stock prices for SLB and SYY work as expected.

Last edited by Steve R. on Mon Nov 06, 2017 10:08 pm, edited 5 times in total.
jsalatas
Registered Member
Posts
51
Karma
2
OS

Re: Currency Quotes

Mon Nov 06, 2017 2:11 am
Steve R. wrote:I attempted to apply the solution posted by jsalatas on November 4, 2017.


I didn't post it. I just verified that it worksfor me. Credits should be given to @ipwizard :)
alainpetit
Registered Member
Posts
10
Karma
0

Re: Currency Quotes

Tue Nov 07, 2017 6:52 pm
@SteveR

I don't know if that is going to work ... but I had to change the symbol to some of my asset from "VUN" to "TSE:VUN". In your case ... would NYSE:SON (for Sonoco Products ?) works

Setting :
url : https://finance.google.com/finance?q=%1
Symbol : %1
Price : "price"\s+content="((\d+|\d{1,3}(?:[,]\d{3})).\d+)
Date : "quoteTime"\s+content="(\d{4}-\d{2}-\d{2})T
Date Format : %y-%m-%d
User avatar Steve R.
Registered Member
Posts
13
Karma
0

Re: Currency Quotes

Tue Nov 07, 2017 9:43 pm
@alainpetit: Changing "SON" to "NYSE:SON" worked. Thanks for the tip.
aperali
Registered Member
Posts
15
Karma
0

Re: Currency Quotes

Wed Nov 08, 2017 1:47 pm
Hi,

Thank you very much! It also worked for me.
alainpetit
Registered Member
Posts
10
Karma
0

Re: Currency Quotes

Wed Nov 08, 2017 5:58 pm
@All:

Eureka, I've made a awesome discovery, and I have to share it with all here that were interested in this issue. Moving to Google Finance was good 99% of the time, but based on my own problems with ETH currency, I couldn't find a one solution to suit all. Until now ... I've found a little unknown currency tracker that works with ALL currency and crypto :

Code: Select all
Kmymoney Settings
URL : https://fx-rate.net/%1/%2
Symbol : href="https:\/\/fx-rate.net\/([^\/]+\/[^\/]+)
Price : 1\s[^=]+\s=<\/span><br\s\/>\s([^\s]+)
Date : updated\s\d+:\d+:\d+\(\w+\)\s(\d{1,2}\/\d{2}\/\d{4})
Date Format : %d/%m/%y
Skip Stripped HTML : CHECKED
myklmar
Registered Member
Posts
1
Karma
0

Re: Currency Quotes

Sat Nov 11, 2017 7:30 pm
Brilliant!
That solved it for me....thanks. :*
User avatar fordtaunus
Registered Member
Posts
4
Karma
0

Re: Currency Quotes

Wed Nov 15, 2017 8:51 am
OK, now that we got it working again, I become greedy :D

Does anyone here a currency exchange that works well with KMyMoney for crypto coins? I definitely need exchange rates for BTC, ETH, BCH and ETC to EUR, but the more the better. On the other hand it doesn't really need to support "real" currencies ;)

Thanks in advance for any help!
User avatar ipwizard
KDE Developer
Posts
455
Karma
1
OS

Re: Currency Quotes

Wed Nov 15, 2017 9:02 am
At least BTC and ETH are supported by fx-rate and work with the proposed solution: https://fx-rate.net/ETH/EUR, https://fx-rate.net/BTC/EUR


ipwizard, proud to be a member of the KMyMoney forum since its beginning. :-D
openSuSE Leap 42.2 64bit, KF5
tartarkde
Registered Member
Posts
3
Karma
0

Re: Currency Quotes

Mon Nov 27, 2017 6:01 pm
ipwizard wrote:At least BTC and ETH are supported by fx-rate and work with the proposed solution: https://fx-rate.net/ETH/EUR, https://fx-rate.net/BTC/EUR


Apologies, but I must be doing something wrong. Could anyone help me out?

I think I have added FX-rate correctly:

https://imgur.com/zcxlKdu

Then, I have a "Cryptocurrencies" investment (type Investment, currency Euro) and under this I created two investments, one for ETH and one for BTC.

As investment type I selected "stock", and this is the configuration: https://imgur.com/ixA8044 (and as a source for the online quotes I'm using FX-rate.net).

When I tried to update the prices, it gives me this error:

Code: Select all
Fetching URL ...
Malformed URL .
Unable to update price for BTC (empty quote data)


Any help will be appreciated, thank you!
User avatar ipwizard
KDE Developer
Posts
455
Karma
1
OS

Re: Currency Quotes

Mon Nov 27, 2017 7:51 pm
Malformed URL is the reason. I don't see why though. Which version of KMyMoney do you use?

Try to locate the file kmymoneyrc in your users directory tree. Depending on the version of KDE this might be different.

Inside this file locate the KMyMoney Currency section

Code: Select all
[Online-Quote-Source-KMyMoney Currency]
CSVURL=
DateFormatRegex=%d/%m/%y
DateRegex=updated\\s\\d+:\\d+:\\d+\\(\\w+\\)\\s+(\\d{1,2}/\\d{2}/\\d{4})
IDBy=0
IDRegex=https://fx-rate.net/([^/]+/[^/]+)
PriceRegex=1\\s[^=]+\\s=</span><br\\s/>\\s([^\\s]+)
SkipStripping=true
URL=https://fx-rate.net/%1/%2

Make sure, that there is nothing located after the %2 of the URL entry. How does this look for you?


ipwizard, proud to be a member of the KMyMoney forum since its beginning. :-D
openSuSE Leap 42.2 64bit, KF5
tartarkde
Registered Member
Posts
3
Karma
0

Re: Currency Quotes

Mon Nov 27, 2017 8:04 pm
ipwizard wrote:Malformed URL is the reason. I don't see why though. Which version of KMyMoney do you use?

Try to locate the file kmymoneyrc in your users directory tree. Depending on the version of KDE this might be different.

Inside this file locate the KMyMoney Currency section

Code: Select all
[Online-Quote-Source-KMyMoney Currency]
CSVURL=
DateFormatRegex=%d/%m/%y
DateRegex=updated\\s\\d+:\\d+:\\d+\\(\\w+\\)\\s+(\\d{1,2}/\\d{2}/\\d{4})
IDBy=0
IDRegex=https://fx-rate.net/([^/]+/[^/]+)
PriceRegex=1\\s[^=]+\\s=</span><br\\s/>\\s([^\\s]+)
SkipStripping=true
URL=https://fx-rate.net/%1/%2

Make sure, that there is nothing located after the %2 of the URL entry. How does this look for you?


Thank you for your reply! However, after I edited my kmymoneyrc file adding the above configuration, it still doesn't work.

The error it returns is still

Code: Select all
Fetching URL ...
Malformed URL .
Unable to update price for BTC (empty quote data)


(I made sure to select the updated entry for the price update)

 
Reply to topic

Bookmarks



Who is online

Registered users: 1ykos, Baidu [Spider], Bing [Bot], bionan, boudewijn, Exabot [Bot], Google [Bot], JesusM, johnguicar, La Ninje, Majestic-12 [Bot], paulus3005, raddison, SleepySapphy, Sogou [Bot], Yahoo [Bot]