Skip Menu |
 

This queue is for tickets about the Finance-Quote CPAN distribution.

Report information
The Basics
Id: 49337
Status: rejected
Worked: 10 min
Priority: 0/
Queue: Finance-Quote

People
Owner: eco [...] ecocode.net
Requestors: piggymarketsqueak [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 1.16
Fixed in: (no value)



Subject: france and bourso quotation as well as currency exchange rates
Hi, I am using Gnucash for a while which is based on Finance::Quote 1.16 for updating currency exchange rates as well as stock and share quotations. I am updating my quotations using the "france" option providing in gnucash which I believe is based on Finance::Quote::Bourso. Recently updating the exchange rates from GBP to EUR started to fell. Now stocks and share quotation are felling as well. this happen when you have Fund set up with source quote information set to "Unknown , france", you multiple currencies account and you go in the menu Tools -> Price Editor and click GetQuotes. You will then receive an error message as in the file attached. That unfortunatly the only error message available at the moment. Could any one point me out were to look out to fix these problem and/or if there is any fix in progress? I am not very familiar with perl but I may be able to help. Disrtibution name : ubuntu 8.10 perl -v : This is perl, v5.8.8 built for i486-linux-gnu-thread-multi uname -a : Linux guil2000 2.6.24.3-custom #3 Sun Dec 14 15:27:48 GMT 2008 i686 GNU/Linux Guillaume.
Subject: gnucash-financequote.png
Download (untitled) / with headers
text/plain 384b
I had the same problem. I modified the "bourso" plugin to make it work. In "bourso", the problem was with delayed OPCVM. It uses a different html page so the regular stock parser don't work with it. I'm still trying to find a documentation on how to submit a patch to this project. I probably won't have the time to create a regular patch today. So here is the raw patch (diff -u).
Download bourso.raw.patch
text/x-diff 2.6k
--- Bourso.ori.pm 2009-10-05 19:39:57.000000000 +0200 +++ Bourso.vN.pm 2009-11-08 20:55:22.000000000 +0100 @@ -121,7 +121,7 @@ }; my $symbol = $symbolline[0]->as_text; - ($symbol) = ($symbol=~m/(\w+)-/); + ($symbol) = ($symbol=~m/(\w+) ?-/); $info{$stocks,"symbol"}=$symbol; # retrieve NAME @@ -139,31 +139,70 @@ # set method $info{$stocks,"method"} = "bourso" ; + #holds table data + my %tempinfo; + # retrieve other data my $infoclass = ($tree->look_down('class','info1'))[0]; unless ($infoclass) { - $info {$stocks,"success"} = 0; - $info {$stocks,"errormsg"} = "$stocks retrieval not supported."; - next ; - }; + my $opcvm = ($tree->look_down('id','cours_HeaderOPCVM_0'))[0]; + unless ($opcvm) { + $info {$stocks,"success"} = 0; + $info {$stocks,"errormsg"} = "$stocks retrieval not supported."; + next ; + } + + # the stock is a delayed OPCVM + + my $infoelem = ($tree->look_down('id','content-gauche'))[0]; + $infoelem = ($infoelem->look_down('class','TabContenu'))[1]; + $infoelem = ($infoelem->look_down('_tag','table'))[1]; + + my @rows = $infoelem->look_down('_tag','tr'); + foreach my $i (0..$#rows) { + my $row = $rows[$i]; + unless($row->attr('class')) { + next; + } + + my $keytext = (($row->look_down('align','left'))[0])->as_text; + my $valuetext = (($row->look_down('align','right'))[0])->as_text; + $tempinfo{$keytext} = $valuetext; + } + } + else { my $keys = ($infoclass->look_down('class','t01'))[0]; # this div contains all keys my $data = ($infoclass->look_down('class','t03'))[0]; # this div contains all values my @keys = $keys->look_down('_tag','li'); my @values = $data->look_down('_tag','li'); - my %tempinfo; #holds table data - foreach my $i (0..$#keys) { my $keytext = ($keys[$i])->as_text; my $valuetext = ($values[$i])->as_text; $tempinfo{$keytext} = $valuetext; } + } + foreach my $key (keys %tempinfo) { # print "$key -> $tempinfo{$key}\n"; ASSIGN: for ( $key ) { + # OPCVM + /Valeur liquidative/ && do { + my ($last, $currency) = ($tempinfo{$key} =~ m/(\d*.?\d*)\s*(\w*)/); + $info{$stocks,"last"} = $last; + $info{$stocks,"currency"} = $currency; + }; + /Date/ && do { + $info{$stocks,"date"} = $tempinfo{$key}; + $quoter->store_date(\%info, $stocks, {eurodate => $info{$stocks,"date"}}); + }; + /Variation Veille/ && do { + $info{$stocks,"p_change"}=$tempinfo{$key} + }; + # REGULAR STOCK /Cours/ && do { my ($last, $currency) = ($tempinfo{$key} =~ m/(\d*.?\d*)\(c\)\s*(\w*)/); $info{$stocks,"last"} = $last;
Download (untitled) / with headers
text/plain 878b
TEST CASE: BEFORE: # gnc-fq-dump bourso FR0000937070 Finance::Quote fields Gnucash uses: symbol: FR0000937070 (deduced) <=== required date: ** missing ** <=== required currency: ** missing ** <=== required last: <=\ nav: <=== one of these price: <=/ timezone: <=== optional ** This stock quote cannot be used by gnucash!! AFTER: # gnc-fq-dump bourso FR0000937070 Finance::Quote fields Gnucash uses: symbol: FR0000937070 <=== required date: 11/06/2009 <=== required currency: EUR <=== required last: 53.03 <=\ nav: <=== one of these price: <=/ timezone: <=== optional
Download (untitled) / with headers
text/plain 211b
hi mate, Thanks for your reply. Unfortunately, I am not very experienced using perl and CPAN projects. Could tell me how to apply your patch and rebuild so that it going to run on my box. Many thanks, Guillaume.
reformatted raw patch. re-created patch using: git diff
Download bourso.patch
text/x-diff 2.6k
diff --git a/lib/Finance/Quote/Bourso.pm b/lib/Finance/Quote/Bourso.pm index 5166794..86bd3b0 100644 --- a/lib/Finance/Quote/Bourso.pm +++ b/lib/Finance/Quote/Bourso.pm @@ -121,7 +121,7 @@ sub bourso { }; my $symbol = $symbolline[0]->as_text; - ($symbol) = ($symbol=~m/(\w+)-/); + ($symbol) = ($symbol=~m/(\w+) ?-/); $info{$stocks,"symbol"}=$symbol; # retrieve NAME @@ -139,31 +139,70 @@ sub bourso { # set method $info{$stocks,"method"} = "bourso" ; + #holds table data + my %tempinfo; + # retrieve other data my $infoclass = ($tree->look_down('class','info1'))[0]; unless ($infoclass) { - $info {$stocks,"success"} = 0; - $info {$stocks,"errormsg"} = "$stocks retrieval not supported."; - next ; - }; + my $opcvm = ($tree->look_down('id','cours_HeaderOPCVM_0'))[0]; + unless ($opcvm) { + $info {$stocks,"success"} = 0; + $info {$stocks,"errormsg"} = "$stocks retrieval not supported."; + next ; + } + + # the stock is a delayed OPCVM + + my $infoelem = ($tree->look_down('id','content-gauche'))[0]; + $infoelem = ($infoelem->look_down('class','TabContenu'))[1]; + $infoelem = ($infoelem->look_down('_tag','table'))[1]; + + my @rows = $infoelem->look_down('_tag','tr'); + foreach my $i (0..$#rows) { + my $row = $rows[$i]; + unless($row->attr('class')) { + next; + } + + my $keytext = (($row->look_down('align','left'))[0])->as_text; + my $valuetext = (($row->look_down('align','right'))[0])->as_text; + $tempinfo{$keytext} = $valuetext; + } + } + else { my $keys = ($infoclass->look_down('class','t01'))[0]; # this div contains all keys my $data = ($infoclass->look_down('class','t03'))[0]; # this div contains all values my @keys = $keys->look_down('_tag','li'); my @values = $data->look_down('_tag','li'); - my %tempinfo; #holds table data - foreach my $i (0..$#keys) { my $keytext = ($keys[$i])->as_text; my $valuetext = ($values[$i])->as_text; $tempinfo{$keytext} = $valuetext; } + } + foreach my $key (keys %tempinfo) { # print "$key -> $tempinfo{$key}\n"; ASSIGN: for ( $key ) { + # OPCVM + /Valeur liquidative/ && do { + my ($last, $currency) = ($tempinfo{$key} =~ m/(\d*.?\d*)\s*(\w*)/); + $info{$stocks,"last"} = $last; + $info{$stocks,"currency"} = $currency; + }; + /Date/ && do { + $info{$stocks,"date"} = $tempinfo{$key}; + $quoter->store_date(\%info, $stocks, {eurodate => $info{$stocks,"date"}}); + }; + /Variation Veille/ && do { + $info{$stocks,"p_change"}=$tempinfo{$key} + }; + # REGULAR STOCK /Cours/ && do { my ($last, $currency) = ($tempinfo{$key} =~ m/(\d*.?\d*)\(c\)\s*(\w*)/); $info{$stocks,"last"} = $last;
Download (untitled) / with headers
text/plain 519b
Hello, On Sun Nov 08 16:19:04 2009, guill wrote: Show quoted text
> Unfortunately, I am not very experienced using perl and CPAN projects. > Could tell me how to apply your patch and rebuild so that it going to > run on my box.
If you want to quickly apply the patch: * locate your finance quote install dir. on my box it's either: /usr/local/share/perl/5.10.0/Finance/Quote or: /usr/share/perl5/Finance/Quote * cd into it * apply the raw patch: patch Bourso.pm /tmp/bourso.raw.patch That's it, nothing to rebuild. Cheers, Laurent
From: laurent.wozniak [...] gmail.com
Download (untitled) / with headers
text/plain 139b
Site has changed its layout, it's broken again.<br /> <br /> Here is the update of the patch that matches the new site.<br /> <br /> <br />
Subject: bourso.v2.patch
Download bourso.v2.patch
text/x-diff 2.6k
diff --git a/lib/Finance/Quote/Bourso.pm b/lib/Finance/Quote/Bourso.pm index 5166794..18ff338 100644 --- a/lib/Finance/Quote/Bourso.pm +++ b/lib/Finance/Quote/Bourso.pm @@ -121,7 +121,7 @@ sub bourso { }; my $symbol = $symbolline[0]->as_text; - ($symbol) = ($symbol=~m/(\w+)-/); + ($symbol) = ($symbol=~m/(\w+) ?-/); $info{$stocks,"symbol"}=$symbol; # retrieve NAME @@ -139,31 +139,71 @@ sub bourso { # set method $info{$stocks,"method"} = "bourso" ; + #holds table data + my %tempinfo; + # retrieve other data my $infoclass = ($tree->look_down('class','info1'))[0]; unless ($infoclass) { - $info {$stocks,"success"} = 0; - $info {$stocks,"errormsg"} = "$stocks retrieval not supported."; - next ; - }; + my $opcvm = ($tree->look_down('id','opcvm_headerFund_0'))[0]; + unless ($opcvm) { + $info {$stocks,"success"} = 0; + $info {$stocks,"errormsg"} = "$stocks retrieval not supported."; + next ; + } + + # the stock is a delayed OPCVM + + my $infoelem = ($tree->look_down('id','content-gauche'))[0]; + $infoelem = ($infoelem->look_down('class','TabContenu'))[0]; + + my @rows = $infoelem->look_down('_tag','tr'); + foreach my $i (0..$#rows) { + my $row = $rows[$i]; + unless($row->attr('class')) { + next; + } + + my @cells = $row->look_down('_tag','td'); + my $keytext = ($cells[0])->as_text; + my $valuetext = ($cells[2])->as_text; + + $tempinfo{$keytext} = $valuetext; + } + } + else { my $keys = ($infoclass->look_down('class','t01'))[0]; # this div contains all keys my $data = ($infoclass->look_down('class','t03'))[0]; # this div contains all values my @keys = $keys->look_down('_tag','li'); my @values = $data->look_down('_tag','li'); - my %tempinfo; #holds table data - foreach my $i (0..$#keys) { my $keytext = ($keys[$i])->as_text; my $valuetext = ($values[$i])->as_text; $tempinfo{$keytext} = $valuetext; } + } + foreach my $key (keys %tempinfo) { # print "$key -> $tempinfo{$key}\n"; ASSIGN: for ( $key ) { + # OPCVM + /Valeur liquidative/ && do { + my ($last, $currency) = ($tempinfo{$key} =~ m/(\d*.?\d*)\s*(\w*)/); + $info{$stocks,"last"} = $last; + $info{$stocks,"currency"} = $currency; + }; + /Date/ && do { + $info{$stocks,"date"} = $tempinfo{$key}; + $quoter->store_date(\%info, $stocks, {eurodate => $info{$stocks,"date"}}); + }; + /Variation Veille/ && do { + $info{$stocks,"p_change"}=$tempinfo{$key} + }; + # REGULAR STOCK /Cours/ && do { my ($last, $currency) = ($tempinfo{$key} =~ m/(\d*.?\d*)\(c\)\s*(\w*)/); $info{$stocks,"last"} = $last;
RT-Send-CC: laurent.wozniak [...] gmail.com
Download (untitled) / with headers
text/plain 431b
On Thu Dec 31 13:14:09 2009, laurent.wozniak wrote: Show quoted text
> Site has changed its layout, it's broken again.<br /> > <br /> > Here is the update of the patch that matches the new site.<br /> > <br /> > <br />
Hi Laurent ! Sorry for the delay... The patch has been applied and tested and moved to master branch. However, what does this patch resolve ? since no test broke with current version neither... thanks for the coding ! -- Erik
From: laurent.wozniak [...] gmail.com
Download (untitled) / with headers
text/plain 623b
Hello, Show quoted text
> The patch has been applied and tested and moved to master branch.
Thank you very much Show quoted text
> However, what does this patch resolve ? since no test broke with > current version neither...
The layout of the site is completely different depending on the type of financial instrument. Layout for a regular stock: http://www.boursorama.com/cours.phtml?symbole=1rPFTE Layout for a delayed opcvm: http://www.boursorama.com/opcvm/opcvm.phtml?symbole=MP-804068 That's why I was talking about the following test case: # gnc-fq-dump bourso FR0000937070 But I don't know how to add a unit test in this project. Cheers, Laurent
Download (untitled) / with headers
text/plain 814b
On Sat Feb 13 10:29:12 2010, laurent.wozniak wrote: Show quoted text
> Hello, >
> > The patch has been applied and tested and moved to master branch.
> Thank you very much >
> > However, what does this patch resolve ? since no test broke with > > current version neither...
> The layout of the site is completely different depending on the type of > financial instrument. > Layout for a regular stock: > http://www.boursorama.com/cours.phtml?symbole=1rPFTE > Layout for a delayed opcvm: > http://www.boursorama.com/opcvm/opcvm.phtml?symbole=MP-804068 > > That's why I was talking about the following test case: > # gnc-fq-dump bourso FR0000937070 > > But I don't know how to add a unit test in this project. > > Cheers, > Laurent
Laurent, I didn't respond for long... Is this still actual or can I close this bug ? -- Erik
Download (untitled) / with headers
text/plain 171b
Show quoted text
> Laurent, > > I didn't respond for long... Is this still actual or can I close this bug ?
I'll close this bug for now.. reopen it if you think it should be ;) -- Erik


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.