Mike/Edward, I'm not sure if either of you have seen Vince's posting in Finance-quote-devel <finance-quote-de...@lists.sourceforge.net> which seems like he's working on a similar thing?
Copy below.... Cheers Dave H Hi, In June, Erik sent a message about his idea for cleaning up the FQ API to have consistent ways to set/get instance variables and expand new to allow for named parameters and module specific data. One benefit is a sustainable way to enable users to register API keys for specific modules. I just pushed the branch "new-new" to explore these ideas. See the file https://raw.githubusercontent.com/finance-quote/finance-quote/new-new/new-API-notes.txt for details about the set/get methods. I used the new API to thread an API key to the IEXCloud module from the test suite as an example: https://raw.githubusercontent.com/finance-quote/finance-quote/new-new/t/iexcloud.t If there is agreement to proceed with the API update there are a few things to do and I can help: - updating the POD documentation for Quote.pm - enabling AlphaVantage to use the module specific data as another source for its API key - renew discussion with gnucash developers on enabling users to specify API keys for more modules Best, Vince On Sun, 19 Jan 2020 at 12:52, Mike Alexander <m...@msalexander.com> wrote: > I'm glad you're looking at this since it does need some work. However I > think there are a couple of things you're not aware of. I, too, have > quite a ffew currencies in my file (around 30) and by coincidence I was > running a price fetch in the background when I first saw your message. > It completed successfully after fetching all currency quotes as usual. > > You're right that GnuCash fetches one currency per call, but this is the > only API for currencies that F::Q provides. It fetches all the other > quotes for a given source in one call to F::Q. The F::Q currency quote > code has a test for the rate limiting message that AlphaVantage returns > when currency quote fetches come too fast. However at some time in the > past AlphaVantage changed this message. I updated F::Q to look for the > new message and sent a pull request upstream. This pul request has > never been applied which means that the current F::Q does not recognize > when AlphaVantage is trying to tell it to slow down. My copy of F::Q > has this change which is probably why it works for me and not for you. > > The patch is simple, just change it to look for a "Note" field in the > returned data instead of an "Information" field. > > Try this and see if it helps. > > Your change to make GnuCash handle F::Q failures better seems like a > good idea. Putting the delay on GnuCash's side of the API might also be > a good idea, but really shouldn't be necessary. It also would be a > problem for someone who has actually paid for an AlphaVantage > subscription and hence can get currency quotes faster. Some day I hope > that F::Q will find a currency quote source that works better and faster > at which time you wouldn't want the delay in GnuCash. > > Mike > > diff --git a/lib/Finance/Quote.pm b/lib/Finance/Quote.pm > index b66bca9..6703935 100644 > --- lib/Finance/Quote.pm > +++ lib/Finance/Quote.pm > @@ -274,9 +274,9 @@ sub currency { > 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'})); > +# print "Failed: " . $json_data->{'Note'} . "\n" if (($try_cnt < 5) > && ($json_data->{'Note'})); > + sleep (20) if (($try_cnt < 5) && ($json_data->{'Note'})); > + } while (($try_cnt < 5) && ($json_data->{'Note'})); > > my $exchange_rate = $json_data->{'Realtime Currency Exchange > Rate'}->{'5. Exchange Rate'}; > > _______________________________________________ > gnucash-devel mailing list > gnucash-devel@gnucash.org > https://lists.gnucash.org/mailman/listinfo/gnucash-devel > _______________________________________________ gnucash-devel mailing list gnucash-devel@gnucash.org https://lists.gnucash.org/mailman/listinfo/gnucash-devel