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

online update quotes

Tags: None
(comma "," separated)
ramachandran
Registered Member
Posts
1
Karma
0

online update quotes

Wed Feb 12, 2014 11:22 am
Used Financial:Quote with India mutual (AMFI). Code & url are correct. AMFI file gets downloaded into tmp folder. But price is not getting updated.
Similar issue with Yahoo as well in Ubuntu.
Please suggest a solution
mbeenham
Registered Member
Posts
95
Karma
0
OS

Re: online update quotes

Sat Feb 15, 2014 3:56 pm
I currently have a problem with Yahoo too. I'm hoping it is a problem Yahoo will fix.


Linux Mint 17.2
KMyMoney Version 4.7.2
Using KDE Development Platform 4.14.2
Mike H
Registered Member
Posts
15
Karma
0

Re: online update quotes

Sat Feb 15, 2014 7:12 pm
I have what looks like the same problem. All was OK when I last updated KMyMoney's stock prices from Yahoo UK a week ago, but today (Saturday 15th Feb) I get the following error:-

Fetching URL http://uk.finance.yahoo.com/d/quotes.csv?s=BATS.L&f=sl1t1d1...
Internal error in server http://uk.finance.yahoo.com/d/quotes.csv?s=BATS.L&f=sl1t1d1
Unable to update price for BATS.L (empty quote data)

Trying to update the price for any of my stocks produces the same "internal error in server" message.

If anyone has figured out what's causing the error, I'd be grateful for some pointers as to what can be done to fix it.

EDIT:-

I think I may be some way towards a solution...

At the moment, KMyMoney constructs the following url in order to fetch the latest price for, in this example, British American Tobacco:-

http://uk.finance.yahoo.com/d/quotes.csv?s=BATS.L&f=sl1t1d1

If I browse to Yahoo Finance - http://uk.finance.yahoo.com - then enter BATS.L in the "enter symbol" box and click "Lookup" I arrive at the quotes page for British American Tobacco. At the bottom of the page under the heading "Toolbox" there's a link to download the price data. The url for that link is:-

http://download.finance.yahoo.com/d/quotes.csv?s=BATS.L&f=sl1d1t1c1ohgv&e=.csv

Clicking that link produces a download file containing the following data:-

"BATS.L",2996.00,"2/12/2014","10:53am",+3.00,3000.00,3012.50,2985.00,2357832

I think, as far as KMyMoney is concerned, there is redundant data in the downloaded file - presumably because the url contains the wrong (or additional) special tags.

The significant difference, though, is that the link points to download.finance.yahoo.com rather than uk.finance.yahoo.com

Changing that aspect of the link used in KMyMoney gives a new url of:-

http://download.finance.yahoo.com/d/quotes.csv?s=BATS.L&f=sl1t1d1

Using the new link directly in a browser results in a downloaded csv file containing the following data:-

"BATS.L",3047.00,"12:09pm","2/14/2014"

This, to me, looks like the data that KMyMoney is expecting.

Editing the url in the "Online Quotes" section of the Configure KMyMoney part of the settings menu to the following....

http://download.finance.yahoo.com/d/quotes.csv?s=%1&f=sl1t1d1

.... results in the following if I select BATS.L for a price update:-

Fetching URL http://download.finance.yahoo.com/d/quotes.csv?s=BATS.L&f=sl1t1d1...
Symbol found: BATS.L
Price found: 3047.00 (3,047)
Date found: Fri Feb 14 2014
Price for BATS.L updated (id E000032)

I tried running a price update on all my stocks and it seems to work.... but I should stress that this needs a bit of testing and checking that the downloaded data is actually correct before placing any reliance on it.

I'll do a few more checks over the next few days before I let KMyMoney use this revised url to actually apply pricing information to my live KMyMoney file. Meanwhile if anyone sees any holes in what I've suggested, please let me know.

Further update:-

Having had a slightly more detailed look at the data, I have noticed one minor anomaly. When I look at the data for BATS.L on the Yahoo site, the price quoted is 3047.00 pence and the time of that price is 17:09 on Feb 14th, i.e. shortly after the stock market closed on Friday. However, the downloaded raw csv file contains the following data:-

"BATS.L",3047.00,"12:09pm","2/14/2014"

Note that the timestamp for the price says 12:09, not 17:09.

I don't know enough about how KMyMoney uses pricing timestamps to be able to assess if this is a problem or not. As far as I'm aware, the timestamp is used to determine which price is to be retained by KMyMoney if multiple prices for the same stock are downloaded on the same day - but I may be wrong about this. My interest in prices is limited to having a weekly record of the price for each stock that I own, so it doesn't really matter at what time, in a particular day, the stock price is downloaded or timestamped. But there may be issues here of which I am unaware....

If anyone can shed some light on this aspect of pricing downloads, I'd be grateful for your help.

Mike

KMyMoney 4.6.4
Ubuntu 12.04
mbeenham
Registered Member
Posts
95
Karma
0
OS

Re: online update quotes

Sun Feb 16, 2014 8:50 am
Thanks for doing the legwork Mike!
I didn't have time to get into this yesterday but I think you are absolutely right and its simply a server change.
I don't know how Yahoo gathers their data but the timestamp thing looks like the time zone for the Atlantic seaboard being applied (-5 hours).
I suspect that the data was the same when it was on uk.finance.yahoo.com and that kmymoney only uses the date, possibly someone familiar with the source code can confirm that.


Linux Mint 17.2
KMyMoney Version 4.7.2
Using KDE Development Platform 4.14.2
jbateman
Registered Member
Posts
1
Karma
0

Re: online update quotes

Sat May 09, 2015 8:09 pm
Thanks guys for finding a URL that works

Re. time -- Its not used, you can see that from the regex (configure - KMyMoney --> Online quotes --> Yahoo UK)

For me I had to modify the regex in order to get KMyMoney to recongise the quote (for days/months which have a single digit)

The item retrieve was of the form:
Code: Select all
"BATS.L",3640.00,"4:35pm","5/8/2015"


I have modified the Date regex pattern to:
Code: Select all
^[^,]*,[^,]*,[^,]*,"(\d\d?/\d\d?/\d\d\d\d)".*


and now it works (Note the time isn't used)

For people that don't understand regex patterns this is:
  1. From start of the line (the leading ^ says this)
  2. Read upto a comma, then read the comma -- discard them (this being the symbol)
  3. Read upto a comma, then read the comma -- discard them (this being the price)
  4. Read upto a comma, then read the comma --discard them (this being the time)
  5. Read and keep the date which is of the form <digit><optional digit>/<digit><optional digit>/<digit><digit><digit><digit>
  6. Read and discard anything else on the line


The date regex could have been written as:
Code: Select all
^(?:[^,]*,){3}"(\d\d?/\d\d?/\d\d\d\d)"

or
Code: Select all
^(?:[^,]*,){3}"(\d\d?/\d\d?/\d{4})"


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]