GNOME Bugzilla – Bug 339433
TiaaCref price quote dates off by one day
Last modified: 2018-06-29 21:02:09 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)
Reassigning to hampton.
Does this still occur with the most recent gnucash 2.0.x and/or the most recent version of Finance::Quote?
yes, it still happens GnuCash r14731, Finance::Quote 1.12
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.
Created attachment 122075 [details] [review] fix timeless quotes from finance-quote
Applied as r17680 - oh well, this should probably be back-ported, right?
yes, please (back-port)
2.2-branch, r17736
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.