[GNC-dev] Alphavantage strategies
Wm
wm_o_o_o at yahoo.co.uk
Thu Jan 17 20:19:16 EST 2019
On 16/01/2019 14:12, Derek Atkins wrote:
> 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!
Do you really miss the point on purposes? If gnc collects the last
price it doesn't have that is a good thing.
--
Wm
Good evening Mr Bogle. Sleep well.
More information about the gnucash-devel
mailing list