After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 339433 - TiaaCref price quote dates off by one day
TiaaCref price quote dates off by one day
Status: VERIFIED FIXED
Product: GnuCash
Classification: Other
Component: General
git-master
Other All
: Normal minor
: ---
Assigned To: David Hampton
Chris Lyttle
Depends on:
Blocks: backport
 
 
Reported: 2006-04-22 23:04 UTC by David Reiser
Modified: 2018-06-29 21:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fix timeless quotes from finance-quote (492 bytes, patch)
2008-11-06 04:34 UTC, David Reiser
committed Details | Review

Description David Reiser 2006-04-22 23:04:38 UTC
The Price Editor reports a date for TiaaCref quotes which is one day earlier than the actual day.

The TiaaCref server returns data without time information. For example:

CREFstok,223.5287,04/21/2006
CREFstok,223.2338,04/20/2006
CREFequi,87.9970,04/21/2006
CREFequi,88.0668,04/20/2006

Either Finance::Quote or GnuCash is adding a midnight timestamp: (terminal output from Get Quotes, with --debug enabled)

gnucash: [D] (handling-request ("tiaacref" "CREFequi" "CREFstok"))
gnucash: [D] (results (("CREFequi" (symbol . "CREFequi") (gnc:time-no-zone . "2006-04-21 00:00:00") 
(nav . 87.997) (currency . "USD")) ("CREFstok" (symbol . "CREFstok") (gnc:time-no-zone . "2006-04-21
 00:00:00") (nav . 223.5287) (currency . "USD"))))

Price Editor then reports that the NAV of CREFequi was 87.997 on 4/20/06 (instead of the correct 4/21/06)
Comment 1 Chris Shoemaker 2006-04-27 17:43:48 UTC
Reassigning to hampton.
Comment 2 Christian Stimming 2006-09-14 11:03:30 UTC
Does this still occur with the most recent gnucash 2.0.x and/or the most recent version of Finance::Quote?
Comment 3 David Reiser 2006-09-15 03:26:54 UTC
yes, it still happens

GnuCash r14731, Finance::Quote 1.12
Comment 4 David Reiser 2008-11-06 04:33:50 UTC
This bug is related to all the rest of the date-time issues, but has an additional twist because of finance-quote.

gnc-fq-dump -v tiaacref CREFstok

returns 

Finance::Quote fields Gnucash uses:
    symbol: CREFstok             <=== required
      date: 11/04/2008           <=== required
  currency: USD                  <=== required
      last:                      <=\       
       nav: 172.7880             <=== one of these
     price: 172.7880             <=/        
  timezone:                      <=== optional

All fields returned by Finance::Quote for stock CREFstok

stock           field  value
-----           -----  -----
CREFstok     currency: USD
CREFstok         date: 11/04/2008
CREFstok     exchange: TIAA-CREF
CREFstok      isodate: 2008-11-04
CREFstok       method: tiaacref
CREFstok         name: CREF Stock
CREFstok          nav: 172.7880
CREFstok        price: 172.7880
CREFstok      success: 1
CREFstok       symbol: CREFstok

So there is no time field in the quote hash.

echo '(tiaacref "CREFstok")' | gnc-fq-helper

returns

(("CREFstok" (symbol . "CREFstok") (gnc:time-no-zone . "2008-11-04 00:00:00") (nav . 165.8214) (currency . "USD")))

but somewhere between the fq-helper and the price db, gnucash rolls the quote through timespecCanonicalDayTime(), wherein it first runs localtime_r(), to produce, presumably, "2008-11-03 19:00:00" for my Eastern US location. Having now screwed up the date, gnucash runs gnc_tm_set_day_middle() on it to enter the price in the pricedb as of noon on the wrong date.

I believe it is almost _never_ true that finance-quote returns a time of midnight. Certainly for Yahoo USA and Yahoo Europe, the reported time is the local time for the reporting entity. For end-of-trading-day quotes for stocks in Europe and the Americas, that's ok. But for mutual fund quotes that frequently don't have a time associated with them, gnucash will be off by one day for such quotes retrieved in the US and similar Western longitudes.

Attached is a patch that intercepts finance-quote quotes that have no times and uses the "set to noon" repair approach before gnucash proper receives the quote. Works for me, and doesn't yet interfere with the main date/time argument.
Comment 5 David Reiser 2008-11-06 04:34:42 UTC
Created attachment 122075 [details] [review]
fix timeless quotes from finance-quote
Comment 6 Christian Stimming 2008-11-07 21:04:47 UTC
Applied as r17680 - oh well, this should probably be back-ported, right?
Comment 7 David Reiser 2008-11-08 04:17:10 UTC
yes, please (back-port)
Comment 8 Christian Stimming 2008-11-27 11:27:30 UTC
2.2-branch, r17736
Comment 9 John Ralls 2018-06-29 21:02:09 UTC
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=339433. Please update any external references or bookmarks.