[GNC-dev] Alphavantage strategies

Derek Atkins derek at ihtfp.com
Wed Jan 16 09:12:15 EST 2019


Hi,

Wm via gnucash-devel <gnucash-devel at gnucash.org> writes:

[snip]
> Let's consider some simple backoff strategies that gnc could
> implement, feel free to add your own.
>
> Wm's suggestion
> ===============
> only collect if the most recent price is more than 1 day (or 12 hours,
> etc) old [2].  this sort of fits in with the existing post collection
> query, i.e. always store the good prices that have been obtained,
> instead ask the user, "do you want to try and fetch the other prices /
> rates again".  this provides a natural pause to Alphavantage as gnc
> won't be hitting it for prices it just got a second time and would
> only be requesting the prices it didn't get last time.
>
> [2] I use this in my own collections (external to gnc) run by cron,
> some more obscure currency pairs are only available a few hours a day,
> I don't even try if the most recent is less than a day old.

Unless it's changed, the only real "backoff" strategy required is to
sleep for 16 seconds between requests.  Basically, assuming this hasn't
changed recently, they allow 5 requests per minute.  So by sleeping 16
seconds you ensure that 5th request occurs after 60 seconds is up.

It should be pretty easy to implement this delay and still allow full
pulls.  The downside, of course, is that if you have lots of prices to
pull it can take N/4 minutes to get them all, so sure, only refreshing
prices > 12 hours old is probably fine, but I suspect this will still be
an all-or-nothing exercise in general.

Enjoy!

-derek

-- 
       Derek Atkins                 617-623-3745
       derek at ihtfp.com             www.ihtfp.com
       Computer and Internet Security Consultant


More information about the gnucash-devel mailing list