Integration of a new Finance::Quote source in gnucash

Hajo Hindriks hhn10 at gmx.net
Tue Aug 18 11:02:04 EDT 2015


On 12.08.2015 11:16, Lt. Goose wrote:
> Hi Hajo,
>
> Sorry for the delay in the answer, but I wanted to elaborate it so 
> that it is clear and thorough. If you need more information, feel free 
> to ask.
>
> In order to write the new module, I got a lot of information from the 
> Quote Hackers Guide 
> (http://cpansearch.perl.org/src/PJF/Finance-Quote-1.11/Documentation/Hackers-Guide).
>
> I used an existing quote module as a starting point (I can't remember 
> now which one I used, but I think it could be Deka.pm). Change the 
> module name to the one you want and replace all occurrences of that 
> name so that the module is correctly formatted. You'll find more 
> information about this in the guide.
>
> First thing you need to locate is a source (URL) where you can get the 
> quote data. In the end you will retrieve a HTML page with that 
> information. The quote symbol with be the one used to check the URL 
> that you will be querying. Data in the HTML page is usually arranged 
> in a table (ideally with a class name or id or some kind of 
> identifier). I used this guide 
> http://www.nu42.com/2012/04/htmltableextract-is-beautiful.html to 
> extract just the table I'm interested in using its table id, which I 
> found using a DOM inspector in that URL.
>
> If you want an example of this, I used this URL 
> (http://www.bolsamadrid.es/esp/aspx/Empresas/FichaValor.aspx?Ticker=SAN) 
> to extract the quotes for Banco de Santander (SAN). If you inspect the 
> html code, you can see that the prices are located in a table with 
> this id 'ctl00_Contenido_tblPrecios', so you just have to extract all 
> the fields you need. Tweak the perl file and fill in the fields you 
> need for your quotes.
>
> You can test your module (you'll have to configure first F::Q to use 
> it, as stated below) with this command:
>   perl gnc-fq-dump -v MODULE_NAME_HERE YOUR_SYMBOL_HERE
>
>
> * Configuring Finance::Quote and GNUCash with the new module
>   ==============================================
>
> I used the information in this guide 
> (http://stephan.paukner.cc/syslog/archives/401-How-to-add-new-quote-sources-to-GnuCash.html) 
> to add the new module I wrote. You can check it for more details.
>
> The new module that will retrieve the quotes (let's call it 
> newQuote.pm) should be placed in the Finance::Quote subfolder (in my 
> version of Windows, this is located in 
> C:\Perl64\site\lib\Finance\Quote). Afterwards, you have to modify the 
> file Quote.pm in order to include the new module you've just created. 
> You have to edit the file and include the quote name in the @module 
> variable. As an example, change the line:
>       @modules = qw/AEX AIAHK ASEGR ASX BMONesbittBurns BSERO Bourso
> with this one:
>       @modules = qw/AEX AIAHK ASEGR ASX BMONesbittBurns BSERO Bourso 
> newQuote
>
> If you save the changes, you can check if F::Q recognizes your new 
> module with gnc-fq-check (the new module should be listed in the 
> output of that command). If this works, open a new instance of gnucash 
> and assign the fund the new quote source (it should be listed under 
> the 'unknown' selector).
>
>
> Hope this helps.
>
> Gus.
>
> 2015-07-31 18:00 GMT+02:00 <gnucash-user-request at gnucash.org 
> <mailto:gnucash-user-request at gnucash.org>>:
>
>     6. Re: Quote date in gnucash different from retrieved by
>           gnc-fq-dump (Hajo Hindriks)
>
>     ---------- Mensaje reenviado ----------
>     From: Hajo Hindriks <hhn10 at gmx.net <mailto:hhn10 at gmx.net>>
>     To: gnucash-user at gnucash.org <mailto:gnucash-user at gnucash.org>
>     Cc:
>     Date: Fri, 31 Jul 2015 13:21:46 +0200
>     Subject: Re: Quote date in gnucash different from retrieved by
>     gnc-fq-dump
>     Hi Gus
>
>     Would you mind sharing how you accomplished your own source? How
>     did you integrate it in F::Q and how was it recognized in Gnucash?
>     I am a new user and just got F::Q to work, unfortunately I have a
>     fund that it not supported by any of the sources, and the supplier
>     has a page with the price information, so I would like to try to
>     write my own quote source as well.
>
>     Kind regards, Hajo
>
>     _______________________________________________
>     gnucash-user mailing list
>     gnucash-user at gnucash.org <mailto:gnucash-user at gnucash.org>
>     https://lists.gnucash.org/mailman/listinfo/gnucash-user
>
>
Thank you Gus - I managed to write and use my own module to import quotes.

regards, Hajo


More information about the gnucash-user mailing list