[GNC] Finance quote troubleshooting

Geoff cleanoutmyshed at gmail.com
Sat Sep 12 20:57:43 EDT 2020

Well Andreas, this is not looking promising, and I suspect it is beyond 
my capabilities to solve.  Anyway, below are 7.5 further suggestions for 
you to try out at your discretion, ranging from the simple to the extreme.

1. These results have confirmed that your API key is good and you have 
connectivity to Alphavantage.  I very much doubt that your anti-virus 
will be the problem, but it won't hurt to momentarily turn it off to 
double check.

2. My next step would be to completely uninstall your Strawberry Perl 
installation, and double check to see that all related directories have 
been removed (and delete them if not).  Then do a vanilla installation 
exactly as you did on the Sandbox.

3. If that doesn't work, there might be something else on your PC - do 
you have any custom firewall rules for example?  Control Panel -> 
Firewall -> Advanced settings -> Outbound rules etc.

4. We seem to have established that this may be a Perl problem, it is 
definitely not a GnuCash one.  You could seek help on Perl forums 
instead of this list - perhaps https://stackoverflow.com/, or even Reddit.

5. If you feel comfortable, you could hack into the Finance::Quote code 
to try and get some diagnostics instead of just the "Urgh!  Nothing 
back" error from currency-lookup.pl.  The code for the currency function 
in Quote.pm is just calling the Alphavantage API and deciphering the 
results.  Start by removing the "#" at the start of line 277 to see what 
that "Failed" message prints out (see attached screenshot):
   return undef unless ( defined $ALPHAVANTAGE_API_KEY );

   my $try_cnt = 0;
   my $json_data;
   do {
     $try_cnt += 1;
     my $reply = $ua->request(GET "${ALPHAVANTAGE_CURRENCY_URL}"
       . "&from_currency=" . ${from}
       . "&to_currency=" . ${to}
       . "&apikey=" . ${ALPHAVANTAGE_API_KEY} );

     my $code = $reply->code;
     my $desc = HTTP::Status::status_message($code);
     return undef unless ($code == 200);

     my $body = $reply->content;

     $json_data = JSON::decode_json $body;
     if ( !$json_data || $json_data->{'Error Message'} ) {
       return undef;
#     print "Failed: " . $json_data->{'Information'} . "\n" if 
(($try_cnt < 5) && ($json_data->{'Information'}));
     sleep (20) if (($try_cnt < 5) && ($json_data->{'Information'}));
   } while (($try_cnt < 5) && ($json_data->{'Information'}));

   my $exchange_rate = $json_data->{'Realtime Currency Exchange 
Rate'}->{'5. Exchange Rate'};

6. Otherwise, are you are prepared to wipe and rebuild your Windows 10 
installation?  The Sandbox demonstrated it will work on a clean install.

7. The only other suggestion I have (not ideal) is to set up a virtual 
machine to run a Linux distribution to host GnuCash.  Google is your guide:

7.5 Someone else on this list may have some suggestions?

Good luck, and do let us know if you find a solution.


On 12/09/2020 11:32 pm, Andreas Vyrides wrote:
> Dear Geoff,
> Thank you for all your feedback. I have done as you instructed.
> I was able to follow the instructions from the 3 first points with 
> success, as I am able to access the documentation, the demo key, as well 
> as the exchange rates using my own key. Please see the screenshot (6) 
> provided (using my own key)
> I was also able to do a clean install in windows sandbox, which was also 
> a success, where I am able to get forex data from both cmd as well as 
> gnucash (from F::Q) (please see attached screenshot 8).
> The issue at this point in time is that I am not aware of how to 
> proceed, in order to allow F::Q to work on my machine without requiring 
> the use of sandbox. I have already removed and re-installed gnucash and 
> F::Q multiple times without any changes. On first look one of the things 
> that differs from the native windows environment and sandbox is the 
> presence of my antivirus, which would be an unlikely candidate as I have 
> the same antivirus in a desktop computer and F::Q works fine.
> I am open to any type of suggestions.
> I appreciate all your help and feedback helping me deal with this issue.
> Kind Regards
> Andreas Vyrides
> On 12/09/2020 12:19, Geoff wrote:
>> OK Andreas, so this isn't really a GnuCash issue per se, and we seem 
>> to have narrowed down the problem to one of Perl / Finance::Quote / 
>> Alphavantage / Your computer.
>> The next steps are to independently verify the connection from your 
>> computer to Alphavantage.
>> Step 1: Can you access their API documentation page?
>> https://www.alphavantage.co/documentation/
>> Step 2: Can you call their API using their *demo* API Key?
>> https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=USD&to_currency=JPY&apikey=demo 
>> Step 3: Can you call their API using *your* API Key?
>> Don't forget to append your actual API key to the URL:
>> https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=GBP&to_currency=EUR&apikey==__Your_Actual_Key__ 
>> See attached screenshot.
>> If all of the above are working, my recommendation would be to 
>> uninstall Perl and reinstall from scratch *or* (if you have Windows 10 
>> Professional) you could use a Windows 10 Sandbox to do a clean 
>> installation of both GnuCash and Perl to try and further isolate the 
>> cause of the problem.
>> https://www.howtogeek.com/399290/how-to-use-windows-10s-new-sandbox-to-safely-test-apps/ 
>> Good luck!
>> Geoff
>> =====
>> P.S. What version of Windows do you have?
>> P.P.S.  What version of Strawberry Perl are you running?
>> perl -v
>> On 12/09/2020 6:41 pm, Andreas Vyrides wrote:
>>> Dear Geoff and Ralls
>>> After following along with the provided link, I ended up running 
>>> "force install Finance::Quote", to verify the integrity of the 
>>> module, and tried a different API key. The similarities end in the 
>>> post on the 8th of august, where Samantha is able to query 
>>> alphavantage and get a correct exchange rate via the terminal, where 
>>> I am not. Please see the attached screenshot for the information 
>>> described above.
>>> All previous tests that I have run in cmd remain the same
>>> Kind Regards
>>> Andreas Vyrides
>>> On 12/09/2020 08:54, Andreas Vyrides wrote:
>>>> Dear Geoff
>>>> I apologise for the misunderstanding. Yes I did run set my 
>>>> alphavantage key before running the commands. Please see the 
>>>> attached screenshot.
>>>> I will have a close look at the link provided. In case you have any 
>>>> other ideas about why this is happening, please do not hesitate to 
>>>> contact me
>>>> Kind Regards
>>>> Andreas Vyrides
>>>> On 12/09/2020 01:59, Geoff wrote:
>>>>> Dear Andreas
>>>>> Did you set your Alphavantage key as an environment variable before 
>>>>> you ran this test script?  Try entering these commands first:
>>>>> set ALPHAVANTAGE_API_KEY=__Your_Actual_Key__
>>>>> See attached screenshot.
>>>>> See also this long thread on resolving a perl related currency 
>>>>> problem on Windows:
>>>>> http://gnucash.1415818.n4.nabble.com/GNC-Difficulty-with-online-price-retrieval-John-Ralls-tc4720222.html 
>>>>> Regards
>>>>> Geoff
>>>>> =====
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gnc_finance_quote_currency.jpg
Type: image/jpeg
Size: 200662 bytes
Desc: not available
URL: <http://lists.gnucash.org/pipermail/gnucash-user/attachments/20200913/03c93105/attachment-0001.jpg>

More information about the gnucash-user mailing list