[GNC] Finance::Quote sometimes returns stock prices in pence

Kalpesh Patel kalpesh.patel at usa.net
Mon Mar 3 07:51:05 EST 2025


Use the regex method:

 

if ($info{$stocks,"currency"} =~ /GB/) {

# do something if 'GB' is found somewhere in it

}

 

Disclaimer: Be careful about pitfall with just using first two characters
for the division. You should verify that as I have not.

 

From: Adrian Holbrook <megagrumpy at hotmail.com> 
Sent: Monday, March 03, 2025 2:20 AM
To: Kalpesh Patel <kalpesh.patel at usa.net>
Cc: gnucash-user at gnucash.org
Subject: Re: [GNC] Finance::Quote sometimes returns stock prices in pence

 

Thanks for that. I think that the coding should work but there is probably
an error on the Yahoo data where they probably identify the currency as GBP
not as GBp. I am wondering if all the UK LSE stocks are quoted in pence but
the currency identifier is sometimes incorrect - in which case it would be
better to just use the first two letters "GB" to identify which stocks
should be divided by 100?

 Could I test this by just changing the line:

 

 if ( ($info{$stocks,"currency"} eq "GBp")

 

To use a wild card instead of the "p"? Or is there a way to just test the
first two characters?

 

 

 

  _____  

From: Kalpesh Patel <kalpesh.patel at usa.net <mailto:kalpesh.patel at usa.net> >
Sent: 02 March 2025 17:53
To: 'Adrian Holbrook' <megagrumpy at hotmail.com
<mailto:megagrumpy at hotmail.com> >; gnucash-user at gnucash.org
<mailto:gnucash-user at gnucash.org>  <gnucash-user at gnucash.org
<mailto:gnucash-user at gnucash.org> >
Subject: RE: [GNC] Finance::Quote sometimes returns stock prices in pence 

 

>From the latest code you can wrap lines 229 through 234 with following
Perl's if condition clause to bypass the conversion :

if  (!( (uc($stocks) eq "NXR.L") or (uc($stocks) eq "NWG.L") )) {
 ... # actual lines 229 through 234 goes here
}


-----Original Message-----
From: Adrian Holbrook <megagrumpy at hotmail.com
<mailto:megagrumpy at hotmail.com> > 
Sent: Sunday, March 02, 2025 7:04 AM
To: gnucash-user at gnucash.org <mailto:gnucash-user at gnucash.org> 
Subject: [GNC] Finance::Quote sometimes returns stock prices in pence

There is a feature in YahooJSON.pm to convert quotes on the LSE in pence to
pounds by dividing by 100. This works on the majority of quotes  but there
are some that it does not work on such as NWG.L (Natwest) and NXR.L
(Norcross). Looking at the file it appears that the division by 100 is
applied if the stock currency is identified as GBp or GBX and then the
currency is changed to GBP as well. So I assume that the currency on Yahoo
is incorrectly identified as GBP for the two stocks above. I am not sure how
to check this but if anyone can suggest a mod to correct it I would be
grateful.

Regards

adrian





More information about the gnucash-user mailing list