[GNC] Finance::Quote - AlphaVantage Trade Currencies
john
jralls at ceridwen.us
Mon Jul 17 13:02:24 EDT 2023
> On Jul 16, 2023, at 15:52, Bruce Schuck <bschuck at asgard-systems.com> wrote:
>
> Hello again,
>
> At some point I am going to take a break from F::Q, I thought this weekend I was going to escape.
>
> ### For the question, skip to the next ###
>
> Anyway, some time ago the issue was raised about prices from AlphaVantage for LSE traded stocks (see https://github.com/finance-quote/finance-quote/issues/281). While there is an issue, the user's perceived solution was not the answer. Apparently my attempt to explain that the root cause was that the data returned from the AV "GLOBAL_QUOTE" API did *NOT* contain the currency used for the pricing returned.
>
> What the AV module does is assign a currency based on the suffix of the lookup symbol. So stocks like GBP.L and GBPG.L get mapped to GBP. The problem is that GBP.L (Global Petroleum Limited) is traded in GBX (aka GBp) and GBPG.L (Goldman Sachs Access UK Gilts 1-10) is traded in GBP. But the AV module as written cannot differentiate since the currency used is not part of the data. Stocks from South Africa have a similar issue.
>
> Needless to say, since I was not ready to dig into the root cause and not wanting to remove the fix that was meant to convert GBp pricing to GBP pricing based solely on the symbol's suffix, the user decided to go on a rant and throw a tantrum in the comments and had to be blocked from the Finance::Quote repository.
>
> ### Question here ###
>
> The currency for the trades can be gotten from AV, but an additional call using the "SYMBOL_SEARCH" API is necessary. Obviously this would impact the throttling limitation of AlphaVantage. For non-US stocks, this means that including an additional currency lookup an average of 2.5 securities can be fetched per minute. I am curious how many of you all use AV for non-US traded securities? Has the pricing discrepancy affect you, and would you want it corrected even though that means increasing retrieval time due to the extra API usage?
It's not all non-US securities. In AlphaVantage it appears to be only LSE stocks; JSE stocks aren't supported and Tel Aviv stocks support only ILS. The Yahoo JSON module adjusts prices for Zac (South Africa) and ILA (Israel) as well as GBX, but Yahoo JSON apparently includes a currency code to make that easy. That seems to be missing from YahooWeb, perhaps an oversight on Vincent's part. The currency is available on https://finance.yahoo.com/quote/GBP.L prefixed by "Currency In" in div id="quote-header-info <>".
So for AlphaVantage it seems only .L and .IL suffix securities would need to be queried, and maybe only .L unless there are known instances where .IL-suffixed symbols are priced in GBP.
Rather than spending an extra query maybe AlphaVantage.pm could accept a special extra suffix indicating that the user wants quotes to be multiplied by 100, perhaps X, so a request for GBP.L priced in GBP would be GBP.L.X.
Alternatively we could create a GBX, ZAX, and ILA pseudo-currencies in GnuCash and users would create parent accounts in those currencies for stocks quoted that way. That would take a little finessing on users' part because using it would depend both on the currency the stock is quoted in and whether F::Q converts it to the "real" currency.
Regards,
John Ralls
More information about the gnucash-user
mailing list