Online quotes fetching latest stock price but incorrect date; currency exchange rate also not working

ln.mailinglists at iinet.net.au ln.mailinglists at iinet.net.au
Sun Feb 18 17:27:18 EST 2018


Hi Justin,
I've been chasing this issue for a couple of weeks - I'm pretty sure
this is an ASX specific problem. Unfortunately, I think the problem
lies in the alpha vantage data source - we're going to need to chase
up with them to sort a fix, and may then need an update to
Finance::Quote as well. Alternatively, we need to fix ASX.pm (per my
previous post on this issue).
Here's what I've found to date:
1) Finance::Quote pulls data from alphavantage using an address of the
form:
https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=TLS.AX&apikey=*********************
(You can test this directly with your own api key)
From the comments in the Perl alphavantage module, this data set
includes date and time data *if* the market is open. Otherwise it only
returns date data only. The perl module removes the time data and
returns the date data. 
2) As you have observed (and as can be seen from the above link), the
date returned by alpha vantage for normal ASX stocks is *early* by 1
day - for example, the data set I ran on Sunday 19th returned correct
prices for Monday 12th through Friday 16th, but assigned these to
Sunday 11th through Thursday 15th. 
3) I don't believe this can be corrected by timezone shifts - I
suspect that because the alpha vantage module does not return a time,
the perl will (reasonably) assume that the alphavantage data is
returned at mid-night (i.e. if alpha vantage returns 12/2/2018, then
perl/gnucash will treat this as 12/2/2018 00:00 for the purposes of
time zone calcs). If this is the case, it doesn't matter what time
zone shift you apply, it won't change the date. 
I ran a set of test on this in gnucash, and couldn't make the date
change no matter what time zone I chose (I'm on East Coast Australian
time).
4) ETFs and possibly managed funds in general are updated later, and
just the at the moment these get the correct date. e.g.
https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=VAS.AX&apikey=*********************
Further notes on this - a) from comments elsewhere on the net, it
looks as though ETFs/managed funds are only updated once per day, and
b) weird things happen to this data on the weekend - e.g. VAS has
correct price information for Friday 16th, but the next available data
point is 4th Feb. This anomaly gets corrected at the start of the week
(don't think this matters for Gnucash use). 

5) I'm having the same problem with USD currency rates. Maybe a change
in the API or the constants for AUD/USD. I haven't looked into the
code for this yet.
6) All this may change when daylight saving changes here and/or in the
US - right at the moment, the ASX is closing spot on midnight East
Coast US time (alpha vantage reference time zone) - our data may
suddenly start working correctly when daylight saving changes. So
something else to watch for over the next few weeks.
At this stage, I have only spent time running the problem down - I
haven't had time to think about a fix. 
Cheers,
Larry

Date: Sun, 18 Feb 2018 10:10:45 +0800
From: Justin Smith 
To: gnucash-user at gnucash.org
Subject: Online quotes fetching latest stock price but incorrect date;
currency exchange rate also not working
Message-ID:

Content-Type: text/plain; charset="UTF-8"
Hi,
Gnucash is not updating stock quotes correctly for me. The stock price
is
correct but an incorrect date is used.
This is confirmed when testing using gnc-fq-dump. E.g.
ALPHAVANTAGE_API_KEY= gnc-fq-dump alphavantage NAB.AX
Finance::Quote fields Gnucash uses:
symbol: NAB.AX


More information about the gnucash-user mailing list