Thanks John. I read through the code. The price source hierarchy means new prices from PRICE_SOURCE_USER_PRICE would overwrite transaction and stock split price sources. I don't want that. I also don't like the sound of generally inserting prices of source PRICE_SOURCE_INVALID, which would be the lowest hierarchy. So I am thinking I will first add a test with gnc_pricedb_lookup_day_t64() and only insert a new price of PRICE_SOURCE_USER_PRICE if this returns false. Or maybe I'm not thinking about this the right way, because Finance::Quote would do the same overrides I'm concerned about. But Finance::Quote is well established code and process rather than something I'm baking up.
That function's documentation again makes me wonder if I should be trying to do something with the hour and timezone in the datetime.datetime instance: "@param t A time. The price returned will be in the same day as this time according to the local timezone." (I can't really unpack that statement and its implications) Is there general documentation about GnuCash considers time and local time somewhere? Cheers, Noah On Mon, Nov 25, 2024 at 9:41 AM John Ralls < jralls_at_ceridwen_us_6r6jr9qybm4741_5ee90...@icloud.com> wrote: > Yes, there is a limit of one price per day per commodity pair. Note that > the code that enforces it isn’t smart enough to look at the other direction > so you can have different prices for e.g. USD->EUR and EUR->USD and that > will cause trouble in reports. > > There’s a price-source hierarchy, see > https://github.com/Gnucash/gnucash/blob/764157ddeb6e7eb90e4c9fdae00ec51dcfda35ea/libgnucash/engine/gnc-pricedb.h#L164, > that establishes what kind of price source can overwrite an existing price. > > Regards, > John Ralls > > > On Nov 25, 2024, at 07:20, Noerr via gnucash-user < > gnucash-user@gnucash.org> wrote: > > Hi, > > I've made some progress to insert commodity price history into my > GnuCash security price database using the python API. I have a few > questions to finish off my goal. > > I worked from two examples: > https://wiki.gnucash.org/wiki/Stocks/get_prices > and > https://github.com/hjacobs/gnucash-stock-portfolio/blob/master/portfolio.py > > I'm wondering if I need to be thinking about hour of the day or time zones > on the datetime object set on GncPrice.set_time64() ? For the moment, > I'm only setting the date associated with the price. Does the pricedb > accept multiple prices in one day (say, for a market-traded security). My > intention is only to record the close-price for such securities anyway. > > I observe that on dates where my pricedb already had a price from an > existing source (transaction, occasional Finance::Quote update, etc. that a > new price was not added on that day). Is there a limit of one price per > day? > > How do I populate the "Source" and "Type" columns that display in the GUI > Price Database? Currently, my new prices have Source "invalid" and an > empty Type column. > > > p = GncPrice(book) > p.set_time64(price_date ) #price_date is a datetime.datetime object > p.set_commodity(commodity) > p.set_currency(gnc_currency) > p.set_value(price_gnc) > pricedb.add_price(p) > > > [image: Screenshot 2024-11-25 at 07.07.55.png] > > > Thanks! > <Screenshot 2024-11-25 at 07.07.55.png> > _______________________________________________ > gnucash-user mailing list > gnucash-user@gnucash.org > To update your subscription preferences or to unsubscribe: > https://lists.gnucash.org/mailman/listinfo/gnucash-user > ----- > Please remember to CC this list on all your replies. > You can do this by using Reply-To-List or Reply-All. > > > _______________________________________________ gnucash-user mailing list gnucash-user@gnucash.org To update your subscription preferences or to unsubscribe: https://lists.gnucash.org/mailman/listinfo/gnucash-user ----- Please remember to CC this list on all your replies. You can do this by using Reply-To-List or Reply-All.