Updating Prices

There are two ways of updating the prices for your investments. You can either enter the price manually or have KMyMoney fetch it from the web.

Manual Price Updates

You can enter prices for your investments using the same Price Editor as used for currencies.

Online Price Quotes

KMyMoney has the ability to download the latest prices for your securities and currencies via the web.

How Online Quotes Work

At your request, KMyMoney will fetch a page from the web that contains the latest price for each security. By default, prices are fetched from finance.yahoo.com, and are subject to the terms and conditions of that site.

The online quote lookup uses the security's trading symbol to find the price. Therefore, it is important to set the symbol correctly. Yahoo supports stocks from most major world markets, so it's usually just a matter of finding the correct symbol. For example, TietoEnator trades on the Stockholm Stock Exchange market, and its Yahoo symbol is TIEN.ST.

To find the trading symbol for a security supported by Yahoo, use the Symbol Lookup feature at finance.yahoo.com.

Assigning a Quote Source

In order to get online price quotes, you first have to enable it for each security or currency you want updated, by setting a Online Quote Source. This is the name of the service from which the quote should be fetched. KMyMoney ships with several sources to choose from. Yahoo is the recommended default source, and should work for most investments and all currencies.

To assign a quote source for an investment, navigate to the investment summary view for the account in which the security is held. Edit the security by right-clicking it and selecting Edit Investment .... In the Investment Detail Wizard, click Next twice, for the Online Update section. In the Online source dropdown box, select the online source for your needs.

Versions of KMyMoney starting with 0.9 contain support for the Finance::Quote package for obtaining online quotes. This is intended primarily as a convenience for those users converting from the GnuCash finance package, which uses it as its native method. If you do select this option, you should see a different list of sources, those supported by Finance::Quote. If the list is empty, it suggests that the package is not properly installed. See their web site at http://finance-quote.sourceforge.net for more information.

Adjusting a quote

Some online sources do not report the price in a base quantity (e.g., EUR) but in a fraction (e.g., Cent). Using this information as price will produce wrong values for your investments.

If this is the case for your online source, you can use the Factor field to enter an adjusting factor. For the above mentioned example the factor would be 0.01.

The Factor field is only available if a Quote Source has been selected.

Fetching Quotes

Typically, you will update the prices for all your securities and currencies as a single operation. Choose the ToolsUpdate Stock and Currency Prices... menu item to bring up the online price quotes dialog. Press Update All to fetch quotes for all securities and currencies in your KMyMoney file.

Online Stock and Currency Price Update

Adding or Editing Quote Sources

Adding or editing quote sources is not recommended for anyone but the most technical user. You should feel comfortable reading HTML and writing complex regular expressions. If this doesn't sound like you, we recommend writing to the developer's list if none of the quote sources work for you. Ideally, please point us to a web page where these quotes can be obtained. Additionally you can consult with members of the KDE Community Forum for KMyMoney as they may already have a solution available for your needs.

If you do feel up to the challenge, here's how it works. The quote sources are contained in the settings dialog. Choose the SettingsConfigure KMyMoney menu item. From there, choose the Online Quotes section. You can choose an existing source to edit, or create a new one. When you are done with your changes, be sure to press the Update button before exiting the dialog. Your changes are not saved by default.

The first thing to consider in an online quote source is the URL. This is the page that is fetched from the web. You will see a %1 in all sources, and a %2 in currency sources. For investments, %1 is replaced by the trading symbol. For currencies, %1 is replaced by the From currency, and %2 is replaced by the To currency. This URL is then fetched, all HTML tags are (optionally) removed, and that stripped file is then sent to the page parser.

Note that the URL can also be a file: URL, which the quote fetcher takes to be the path to an executable script. It will pass any command-line arguments to it that you have specified, and feed the stdout to the page parser. For example, you might have a script called getquote.sh that contains custom quote logic, taking the symbol as a single parameter. Your URL would be file:/path/to/getquote.sh %1.

The page parser looks for a symbol, a date, and a price. Regular expressions tell it how to extract those items from the page. Please review the documentation for the QRegularExpression class for the exact syntax regular expressions used by KMyMoney. There should be exactly one capture expression, surrounded by parentheses, in each regexp field. The date format further tells the date parser the order of year, month, and day. This date format should always be in the form "%x %x %x". where x is y, m, or d. The date parser is very smart. %m %d %y will parse December 31st, 2005 as easily as 12/31/05. Two digit years are interpreted as being in the range of 1950-2049.