[GNC] gnucash-cli doesn't retrieve quotes from "unknown" sources

Gustavo R. Montesino grmontesino at gmail.com
Wed Dec 27 17:14:30 EST 2023


On Mon, Dec 11, 2023 at 10:27 PM Gustavo R. Montesino
<grmontesino at gmail.com> wrote:
> On Mon, Dec 11, 2023 at 2:20 PM john <jralls at ceridwen.us> wrote:
> > > On Dec 11, 2023, at 03:07, Gustavo R. Montesino <grmontesino at gmail.com> wrote:
> > > > On Sun, Dec 10, 2023 at 9:30 PM john <jralls at ceridwen.us> wrote:
> > > > > On Dec 10, 2023, at 03:40, Gustavo R. Montesino <grmontesino at gmail.com> wrote:
> > > > >
> > > > > I'm running gnucash 5.4 from Debian testing/sid repo and getting
> > > > > updated commodity quotes through "gnucash-cli --quotes get".
> > > > >
> > > > > Recently I've noticed that gnucash-cli isn't getting quotes from
> > > > > "unkonwn" Finance::Quote sources; the same commodities get updated
> > > > > quotes correctly if run from the Price dialog.
> > > > >
> > > > > Running gnucash-cli with "--debug", the affected commodities doesn't
> > > > > show up on the "Query JSON" posted on the console; running the gui
> > > > > with debug they show correctly on gnucash.trace, eg:
> > > > >
> > > > > 8:23:47  INFO <gnc.price-quotes> [GncQuotesImpl::query_fq] Query JSON: {
> > > > >  "defaultcurrency": "BRL",
> > > > > (...)
> > > > >   "tesouro_direto": {
> > > > >       "Tesouro Prefixado 2026": "",
> > > > >       "Tesouro Selic 2027": "",
> > > > > (...)
> > > >
> > > > Does it work correctly if you request individual quotes from gnucash-cli, for example
> > > >    bin/gnucash-cli -Q dump tesouro_direto "Tesouro Prefixado 2026"
> > > >
> > >
> > > Thanks for the reply. Individual/specific quotes work perfectly:
> > >
> > >   ~$ LANG=C gnucash-cli -Q dump tesouro_direto "Tesouro Prefixado 2026"
> > >     Finance::Quote fields GnuCash uses:
> > >        symbol: Tesouro Prefixado 2026<=== required
> > >         date: 12/08/2023      <=== recommended
> > >          currency: BRL             <=== required
> > >          last: 818.37          <=\
> > >           nav:                 <=== one of these
> > >        price:                 <=/
> > >
> > OK, good. Can you figure out when it stopped working and what might have changed in your system around that time?
> >
>
> Hello,
>
> I'm not really sure when this problem started, but the quote
> availability on my pricedb gets visibly irregular since around the end
> of august. Checking the apt logs, although this is some strong
> guesswork, I do think this has stopped working after upgrading to
> gnucash 5 (from 1:4.13-1 to 1:5.1-1 to be precise).
>

Hello,

I've finally managed to take a better look at this, and it would seem
to be a bug related to the order of loading things (at least on a SQL
Backend). "QofSessionImpl::load()" loads the commodities from the book
before "gnc_quote_source_set_fq_installed()" loads the F::Q sources,
leading to the commodity to be associated with a nil source. The
source is loaded later but there is no association to the commodity.

    * 17:27:15 DEBUG <qof.session> [enter
./libgnucash/engine/qofsession.cpp:QofSessionImpl::load()]
sess=0x56308ef63be0 uri=quotes-test.gnucash
    * 17:27:15 DEBUG <gnc.backend.dbi>     [enter
./libgnucash/backend/dbi/gnc-backend-dbi.cpp:GncDbiBackend<Type>::load()]
dbi_be=0x56308ef64000, book=0x56308f077060
      (...)
    * 17:27:15 DEBUG <gnc.commodity>
[gnc_quote_source_lookup_by_internal]
gnc_quote_source_lookup_by_internal: Unknown source tesouro_direto
    * 17:27:15 DEBUG <gnc.commodity>         [enter
./libgnucash/engine/gnc-commodity.c:gnc_commodity_set_quote_source()]
(cm=0x56308efd36d0, src=(nil)(unknown))
     (...)
    * 17:27:16 DEBUG <gnc.commodity> [enter
./libgnucash/engine/gnc-commodity.c:gnc_quote_source_set_fq_installed()]
    * 17:27:16 DEBUG <gnc.commodity>
[gnc_quote_source_lookup_by_internal]
gnc_quote_source_lookup_by_internal: Unknown source tesouro_direto
    * 17:27:16 DEBUG <gnc.commodity>     [gnc_quote_source_add_new]
Creating new source tesouro_direto

I´m not versed enough on gnucash source to say if this is the best
course of action, but this comment on gnc-commodity.c seems to
indicate that at some point the intention was to call
"gnc_quote_source_add_new()" when an commodity with unknown source is
found, instead of associating it with a null source:

    /********************************************************************
     * gnc_quote_source_add_new
     *
     * Add a new price source. Called when unknown source names are found
     * either in the F::Q installation (a newly available source) or in
     * the user's data file (a source that has vanished but needs to be
     * tracked.)
     ********************************************************************/

Perhaps this would be better registered on bugzilla? Taking a look
around it does actually seem to be already reported on 799066.


Thanks and regards,

Gustavo R. Montesino


More information about the gnucash-user mailing list