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

[Script] Updating Spanish stock prices automatically

Tags: stock, yahoo, prices, update stock, yahoo, prices, update stock, yahoo, prices, update
(comma "," separated)
Ivan Perez
Registered Member
Posts
40
Karma
0
Dear KMyMoneyMakers,

This is not so much a question as a solution that others might find helpful.

For quite some time, Yahoo has stopped giving live quotes for the Spanish stock market [1]. That means that updating from Yahoo fails for all .MC-ending stocks (Madrid), among others.

It used to be the case that prices could be downloaded from:
http://finance.yahoo.com/d/quotes.csv?s=%1&f=sl1d1
which is what has stopped working.
However, historical prices are still available and, except for day-traders, they are updated frequently enough. These are available at:
http://ichart.finance.yahoo.com/table.csv?s=%1&ignore=.csv&f=sl1d1

Following the advice on [2], I decided to create an alternative source for these quotes. I'm posting here the script that I'm using to get them, plus the regexps used to obtain each field. I hope they are useful to others as well:

Script:
#!/bin/bash
EXPR="s/^/$1,/g"
wget --quiet -O - "http://ichart.finance.yahoo.com/table.csv?s=$1&ignore=.csv&f=sl1d1" | head -n 2 | tail -n 1 | sed -e $EXPR

Script details on KMyMoney:
URL: file:///<some_path_in_your_system>/getquote %1
Symbol: ^([^,]*),
Price: ,([^,]*)$
Date: ^[^,]*,([^,]*),
Date format: %y-%m-%d

If you find a problem, an alternative source or a better solution, please respond to this thread.

Cheers

Ivan

PS: Just so that google associates this post to the right keywords, I'm adding a bunch of related Spanish keywords here:
bolsa, actualizar, precios, automatico, automaticamente, valores, cartera, problema, error

[1] https://es.ayuda.yahoo.com/kb/finance/N ... sions=true
[2] viewtopic.php?f=69&t=122830
Ivan Perez
Registered Member
Posts
40
Karma
0
By the way, the string after the GET parameter "f" has no effect watsoever, afaict. I tried with or without it, the output is the same.
User avatar
Hei Ku
Registered Member
Posts
784
Karma
3
OS
Thanks a lot.

If others confirm it's working, we can add it to our default settings in the new version.


Hei Ku, proud to be a member of the KMyMoney Development Team since January-2008


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], q.ignora, watchstar