[GNC] Yahoo JSON - throwing unauthorized error

john jralls at ceridwen.us
Mon May 8 23:56:36 EDT 2023



> On May 8, 2023, at 2:00 PM, Bruce Schuck <bschuck at asgard-systems.com> wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On 5/8/23 13:05 PM, R Losey wrote:
> 
> > Others will probably report this, but Alphavantage has a built-in
> > one minute delay for every 5 (I think 5)prices you look up; for
> > example: 4 stocks: may take 7 seconds; 6 proces: 1 minute, 7 seconds;
> > 12 prices: 2 minutes, 10 seconds..
> > I am talking about the free version of Alphavantage, by the way.
> Unfortunately the AlphaVantage module throttles the requests regardless of API type (free or premium). Alpha Vantage should have an API that given an API key returns "free" or "premium".
> 
> Since data for more than one stock can be returned from a single API call, it may be worth the time to rewrite the module so it fetches all the quotes at once, or perhaps batches into groups of stocks.
> 
> I really have dug into how GnuCash calls the F::Q tool, but with the possibility that different securities can have different sources, is F::Q called once for each stock? Or does GC group them according to source and make one F::Q invocation for each source?

The latter. 

Alphavantage does provide more quotes/minute for a price: "We are pleased to provide free stock API service for our global community of users for up to 5 API requests per minute and 500 requests per day. If you would like to target a larger API call volume, please visit premium membership." (https://www.alphavantage.co/support/#api-key, "premium membership" is an anchor with href="https://www.alphavantage.co/premium/"). Premiu, pricing starts at $49.95/month for 75 requests per minute.

The api docs indicate only one symbol per request. I tried https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=IBM&symbol=AAPL&apikey=XXXXX and got a quote only for AAPL so it seems the implication is valid.

The throttling is done in F::Q's Alphavantage module (https://github.com/finance-quote/finance-quote/blob/e29e2d7f48473fc65601c0c45a934a03af4d33fc/lib/Finance/Quote/AlphaVantage.pm#L138) and doesn't know how to be conditional on whether the user's API key is premium. It throttles because if you ask for more than 5 quotes at once alphavantage will return 5 and quit, then not answer other requests until a minute has elapsed.

Regards,
John Ralls



More information about the gnucash-user mailing list