Registered Member
|
Has anybody got a neat way to import historical prices for investments?
The "Prices" tool is impractical for this purpose and I would like to get prices in for at least this financial year if at all possible. I didn't start with KMyMoney until June and while I have all the historical transactions (buy,sell etc) the prices associated with the securities prior to June don't exist. This makes a nonsense of portfolio performance graphs for the year. I could get the prices I want to import into a spreadsheet without much difficulty, just need a way to load them... Thanks
Linux Mint 17.2
KMyMoney Version 4.7.2 Using KDE Development Platform 4.14.2 |
Registered Member
|
You don't say from where/what you want to import. Hopefully, you can export a qif file with all your prices? If so, then you might need to tinker with the format of the file. What is needed is something like this:- !Option:AutoSwitch !Account NBank A TBank Daccount no ^ NBank B TBank ^ [more accounts then investment accounts] ^ NFirst investment accnt TMutual/stock etc ^ Nnext investment accnt TMutual ^ Ninvestment accnt Tstock ^ Nanother inv Tstock ^ [Then a list of securities with their symbols] !Clear:AutoSwitch !Type:Security NFirst security name Sticker/symbolA TUnit/Inv. Trust ^ !Type:Security Nnext security SsymbolB TUnit/Inv. Trust ^ !Type:Security NsecurityC SsymbolC TUnit/Inv. Trust ^ [Then your prices] !Type:Prices "symbolA",1.4457,"1/12/04" ^ !Type:Prices "symbolA",1.4594,"1/1/05" ^ !Type:Prices "symbolA",1.4589,"1/2/05" ^ !Type:Prices "symbolA",1.4615,"1/3/05" ^ !Type:Prices "symbolB",0.7038,"5/12/01" ^ !Type:Prices "symbolB",0.684,"1/1/02" ^ !Type:Prices "symbolB",0.692,"1/2/02" ^ !Type:Prices "symbolB",0.6816,"1/3/02" ^ !Type:Prices "symbolB",0.6922,"1/4/02" ^ [etc] Hopefully that should import for you. I seem to remember that Quicken tends to put a garbage entry at the end of each accounts prices. aga
aga, proud to be a member of KDE forums since 2008-Nov.
|
Registered Member
|
Many thanks for that.
I exported from MS Money which doesn't provide price information in the QIF unfortunately. All the transactions came across OK but of course I lost price updates until I started updating via KMyMoney (which is much more reliable via Yahoo than MS Money was via MSN). The only way I know to get historical prices is to export them from a MS Money Graph to an Excel spreadsheet and then massage that into the "Prices" format you describe above and create a QIF file. KMyMoney already knows about all my securities so I think all I probably need is lines in the QIF like:
for each price and date I want to import for each symbol in my investments - correct? I will try it out later on a COPY of my KMyMoney file with just a couple of prices for a couple of my investments I will let you know how it goes. Thanks again
Linux Mint 17.2
KMyMoney Version 4.7.2 Using KDE Development Platform 4.14.2 |
Registered Member
|
That worked OK.
I downloaded a test range of historical prices from Yahoo Finance and reformatted:
Imported just fine. Now for the full download (50 stocks) sigh... Thanks for the help.
Linux Mint 17.2
KMyMoney Version 4.7.2 Using KDE Development Platform 4.14.2 |
Registered Member
|
If you workout a script to do that, then we could include it in KMyMoney for future use.
Hei Ku, proud to be a member of the KMyMoney Development Team since January-2008
|
Registered Member
|
Well, since you asked - it ended up part scripted:
1. I downloaded historical prices from Yahoo finance into files e.g. for ABF.L the download looked like:
I used the weekly option and named this file with its symbol ABF.L, similarly for the other securities. 2. I then ran the following script I called qiffles.sh:
./qiffiles.sh > import.qif which massaged and concatenated all my import files into a single QIF:
N.B. The symbol is taken from the downloaded file name so it is important to name it correctly. 3. I then imported into KMyMoney. Job done, start to finish <30 seconds. (+writing the script about 45 minutes, +downloading the files about 10 minutes) It would have been nice to automate the download, but not worth it for a one-off. Hope this helps someone.
Linux Mint 17.2
KMyMoney Version 4.7.2 Using KDE Development Platform 4.14.2 |
Registered Member
|
Thanks a lot. I know this will be helpful to other people.
Hei Ku, proud to be a member of the KMyMoney Development Team since January-2008
|
KDE Developer
|
In case someone wants to automate this further, here's a possible way to extract all symbols and sources from a KMyMoney file:
Usage would be:
or in case you use the compressed form:
or for the GPG to encrypted data:
ipwizard, proud to be a member of the KMyMoney forum since its beginning.
openSuSE Leap 15.4 64bit, KF5 |
Registered Member
|
Can I set currency for quotes? I import the price file. But the currency stated in my default currency KMyMoney.
But I need to specify the currency (US dollars) for these historical prices:
Thanks for the advice! |
Registered Member
|
I found another way to successfully import historical prices https://forum.kde.org/viewtopic.php?f=69&t=165308&p=430514#p430514
|
Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft