[GNC] Currency exchange rates retrieval with GC 3.2

John Ralls jralls at ceridwen.us
Fri Sep 7 23:10:08 EDT 2018



> On Sep 7, 2018, at 4:12 AM, Manfred Usselmann <manfred at usselmann.de> wrote:
> 
> Am 06.09.2018 21:16, schrieb John Ralls:
> 
>> On Sep 6, 2018, at 9:21 AM, Manfred Usselmann <manfred at usselmann.de <mailto:manfred at usselmann.de>> wrote:
>> Am 06.09.2018 16:33, schrieb John Ralls:
>> 
>> 
>> 
>> On Sep 6, 2018, at 12:15 AM, Manfred Usselmann <manfred at usselmann.de <mailto:manfred at usselmann.de>> wrote:
>> 
>> 
>> 
>> Hi, 
>> 
>> I'm using GnuCash 3.2 with Finance::Quote 1.47 on Ubuntu 18.04. 
>> 
>> When trying to download currency exchange rates this fails with "Unknown
>> error". 
>> 
>> I've registered an ALPHAVANTAGE_API_KEY and entered it on the settings
>> screen. 
>> 
>> Some tests from the command line: 
>> 
>> $ GNC-FQ-DUMP -V ALPHAVANTAGE CHFEUR=X
>> Finance::Quote fields Gnucash uses:
>> symbol: CHFEUR=X <=== required
>> date: 09/06/2018 <=== recommended
>> currency: USD <=== required
>> last: 0.8842 <=\ 
>> nav: <=== one of these
>> price: <=/ 
>> timezone: <=== optional 
>> 
>> All fields returned by Finance::Quote for stock CHFEUR=X 
>> 
>> stock field value
>> ----- ----- -----
>> CHFEUR=X close: 0.8842
>> CHFEUR=X currency: USD
>> CHFEUR=X currency_set_by_fq: 1
>> CHFEUR=X date: 09/06/2018
>> CHFEUR=X high: 0.8847
>> CHFEUR=X isodate: 2018-09-06
>> CHFEUR=X last: 0.8842
>> CHFEUR=X low: 0.8840
>> CHFEUR=X method: alphavantage
>> CHFEUR=X open: 0.8845
>> CHFEUR=X success: 1
>> CHFEUR=X symbol: CHFEUR=X
>> CHFEUR=X volume: 0 
>> 
>> $ ECHO '(ALPHAVANTAGE "CSCO")' | GNC-FQ-HELPER
>> (("CSCO" (symbol . "CSCO") (gnc:time-no-zone . "2018-09-05 12:00:00")
>> (last . 47.2700) (currency . "USD")))
>> 
>> Does the CSCO price retrieval work in GnuCash?
>> No, also got unknown error. I'm not sure though that I set it up correctly. The command line was just copied from somewhere, the wiki I believe.
>> 
>> I created a CHFEUR=X security, set it to retrieve quotes from Alphavantage, and successfully retrieved the price in GnuCash.
>> I did not create a security, just a currency account.
>> Note, however, that it's not a meaningful value: CHFEUR=X retrieves the price in EUR of 1CHF, but Finance::Quote treats it as USD because Alphavantage doesn't tell it otherwise.
>> Mmh, but the manual says to use Alphavantage for currencies?
>> Are there any instructions which should work. I just want to download exchange rates... ;-)
>> Unknown error  is not really helpful...  The exact error message is "Beim Herunterladen der Börsenkurse ist ein unbekannter Fehler aufgetragen."
>> Currency quotes are taken care of separately and use a different syntax in gnc-fq-dump and gnc-fq-helper:
>>  
>> gnc-fq-dump currency CHF EUR 
>> echo '(currency "CHF" "EUR")' | gnc-fq-helper 
>>  
>> It does use Alphavantage, but that part is built in to Finance::Quote and GnuCash sends the query shown to gnc-fq-helper for currency accounts.
>>  
>> Yes, we know that "unknown error" isn't very helpful. Unfortunately there's no good way to get more detail about the error from perl to scheme so that's the best we can do. Double check that you correctly copied the API key into GnuCash Preferences, that's the most likely cause of being able to get quotes from the command line but not from within GnuCash.
>>  
>  
> Yes my Alphavantage API key is fine:
>  
> ~$ gnc-fq-dump currency CHF EUR 
> 1 CHF = <unknown> EUR
>  
> $ echo '(currency "CHF" "EUR")' | gnc-fq-helper
> (#f)
>  
> $ export ALPHAVANTAGE_API_KEY=(correkt key)
> 
> $ echo '(currency "CHF" "EUR")' | gnc-fq-helper
> (("EUR" (symbol . "EUR") (gnc:time-no-zone . "2018-09-07 09:48:44") (last . 1.12353) (currency . "CHF")))
> 
> $ gnc-fq-dump currency CHF EUR 
> 1 EUR = 1.12359 CHF
>  
> I got it working now by disabling the online updates for all securities I've got. Probably old codes which are no longer valid.
>  
> Now I get an error message for the currency DEM (Deutsche Mark, you see how long I'm using GnuGash), but I'm asked if I want to continue anyways, which is fine and the correct exchange rate for CHF is retrieved.  
>  
>  
> Thanks a lot for you help!

Very good.

On reflection, having securities pointed at Yahoo! is indeed the most common cause of that problem, followed by not having the correct Alphavantage key in preferences.

Regards,
John Ralls




More information about the gnucash-user mailing list