[GNC] Finance::Quote - AlphaVantage Trade Currencies

John Ralls jralls at ceridwen.us
Mon Jul 17 20:28:19 EDT 2023



> On Jul 17, 2023, at 11:11 AM, Bruce Schuck <bschuck at asgard-systems.com> wrote:
> 
> On 7/17/23 10:02 AM, john wrote:
> 
>> 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 <https://finance.yahoo.com/quote/GBP.L> prefixed by "Currency In" in
>> div id="quote-header-info".
> 
> The currency is being captured by YahooWeb. For GBP.L (traded in GBp/GBX) has its price converted to GBP and currency reported as such. At the time of this writing, GBP.L was 0.1850 GBp, F::Q v1.57 yahooweb returns 0.00185 GBP.
> 
> % gnc-fq-dump -v yahooweb GBP.L
> 
> stock           field  value
> -----           -----  -----
> GBP.L        currency: GBP
> GBP.L            date: 07/17/2023
> GBP.L        exchange: LSE - LSE Delayed Price
> GBP.L         isodate: 2023-07-17
> GBP.L            last: 0.00185
> GBP.L          method: yahooweb
> GBP.L            name: Global Petroleum Limited
> GBP.L         success: 1
> GBP.L          symbol: GBP.L
> 
> > 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.
> 
> I will change the AlphaVantage.pm fix I'm working on to only execute the extra API call for securities ending with '.L'.
> 
>> 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.
> 
> If I understand, this method assumes the user knows that the data from AV for GBP.L is priced in GBp/GBX. Correct?
> 
>> 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.
> 
> F::Q currently sets currency based on suffix. '.L' gets mapped to 'GBP'. I just checked, currently no map in AV for ZAR. By chance, you don't have an example for me? Thanks. Like the previous comment, this also expects users to know what currencies the different securities are reports as coming from the AV module, correct? While I like the idea on a high level, I think that is asking for trouble reports from users having pricing issues.
> 

Bruce,

Sorry, I can't provide any examples of JSE or TASE stocks, I was going completely off of looking at the code in the three modules.

Yes, both of my suggestions transfer the responsibility for knowing what currency a stock is traded in to the user. In GnuCash's case that responsibility is already there. GnuCash doesn't use the currency returned from F::Q, it assumes that the price is denominated in the currency of the nearest parent account denominated in a currency. We don't get that many users who miss that detail and it's pretty easy for them to fix their books. I don't know about other programs using F::Q.

Regards,
John Ralls


More information about the gnucash-user mailing list