[GNC-dev] Robust error handling and respecting the Apha Vantage API limits in gnc-fq-helper.

Mike Alexander mta at umich.edu
Sun Feb 9 17:41:25 EST 2020

On 9 Feb 2020, at 3:49, Edward d'Auvergne wrote:

> That sounds like it would work, however I see quite a different
> behaviour with the debugging (in my first post) and from the code
> (gnucash/price-quotes.scm and libgnucash/quotes/gnc-fq-helper.in).
> What I see in both is that for each iteration of the while loop, F::Q
> is called once per currency.  If the fetch fails, due to the
> Alphavantage API limits, the first result is #<eof>.  This seems to
> cause the guile 'fdes' file descriptor to close.  Hence all subsequent
> currencies are looped through without calling F::Q.
> There is no sleeping in this.  F::Q 1.49 does not recognise serial
> calls.  F::Q's delay is only invoked when a list of currencies is feed
> into it in a single call.  But GnuCash clearly does not do this.
> In any case whether or not the pipe is closed, the loop runs at full
> Perl execution speed, limited solely by the IO.  F::Q currently does
> not insert a sleep period into this loop.  The result is that only the
> first few currencies that are within the Alphavantage API limit will
> be fetched, the rest will be skipped.  From the debugging output, the
> currency skipping is very fast.  This is exactly the behaviour I have
> always seen in GnuCash since the Yahoo API shutdown.

You don't seem to be following what I'm saying.

First, the delay when currency quotes exceed the AlphaVantage rate limit 
is in Finance::Quote itself, not in any code distributed as part of 
GnuCash.  You're right that GnuCash asks for currency exchange rates as 
fast as possible, but this is not relevant to what I'm saying.  As of 
F::Q 1.49 the code in F::Q to rate limit currency exchange rate calls is 
broken.  Earlier I gave a patch to fix this.  If you haven't applied 
this patch to F::Q, GnuCash won't be able to retrieve more than a few 
currency exchange rates.  Have you applied this patch?

Second, you keep saying that GnuCash should ask for multiple currency 
quotes per call to F::Q.  I don't know of any way to do this.  I just 
read the F::Q documentation and code again and can't see any method that 
returns more than one currency exchange rate per call.  How do you do 
this in F::Q?  Is there some undocumented method that I am missing?


More information about the gnucash-devel mailing list