[GNC] Finance::Quote - AlphaVantage Trade Currencies
john
jralls at ceridwen.us
Tue Jul 18 00:07:27 EDT 2023
Bruce forgot to copy the list on this and couldn't find it to resend, and then so did I on the reply!
> On Jul 17, 2023, at 18:57, Bruce Schuck <bschuck at asgard-systems.com> wrote:
> On 7/17/23 5:28 PM, John Ralls wrote:
>
>> 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.
>
> No big deal. I did some searching, and I don't think AlphaVantage has data for securities traded on the Johannesburg Stock Exchange. If someone else reading this can supply an example, please post it.
>
>> 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.
>
> Now here's where I am cloudy. Since GBX is *not* a standard ISO 4217 currency code, a user cannot choose GBX as their default currency, or am I missing something? Currently, without the AlphaVantage module modifying prices for securities such as GBP.L, GnuCash would assume the price is GBP, and it would be wrong. GnuCash would assume the price is 0.18 GBP, when it's 0.18 GBX or 0.0018 GBP.
>
> Which is likely why Erik added the "fix" back in 2017. Since all (or most?) the LSE traded stocks have the ".L" suffix in AV, they all get mapped to GBP. Erik may have tested with a GBp priced security and make the adjusting logic match ".GBP" or ".GBX". Likely he also didn't realize that the suffix ".GBX" was impossible, since it's not in the currency map in the module.
>
> With this in mind, I think the currency check and extra API call needs to be done so securities traded in GBX get adjusted to GBP and GBP priced securities are left alone. To me, that's the simplest fix although for users with a good amount of LSE traded securities, it will slow down the AV throttling.
Well, a user wouldn't want to set GBX as their default currency, just to create an account in their tree denominated in it to be a parent for stock accounts that are priced in GBX. But you're right that it's not something that a user can do now because GBX isn't an ISO4217 currency and that's historically how we decide what's a currency. Implementing it would require making an exception to that policy and adding an entry to our currency file.
To be pure it would also require F::Q to leave the GBX->GBP conversion to the client program, because while it's reasonable to expect a user who owns GBP.L shares to know that they trade in GBX it's not reasonable to expect them to know that it's one of the exceptions that doesn't get adjusted automatically when getting the price from AlphaVantage, but *does* get adjusted automatically when retrieved from Yahoo!. And repeating myself for emphasis, that's how GnuCash could handle it but I have no idea if it's reasonable for other programs. From that standpoint the extra suffix is more straightforward: Just add it and F::Q will unconditionally multiply the price by 100. That will work for any client and is pretty easy to explain to users.
I guess since YohooWeb *does* report the currency that simply documenting that it's a problem is an alternative, and users can be directed to use that instead when they have pricing problems.
Regards,
John Ralls
More information about the gnucash-user
mailing list