Derek, Your point is well-taken; making changes to the datafile outside of the API is Risky.
That being said, the price db operates somewhat independently of a file's transactions. Adding or removing items from the price db can be done without disruption to transactions. I find it interesting to read this announcement; a number of years back, I did a very similar project in perl, which more directly reconstructed a book's commodity prices with monthly prices for all holdings past and present. I was able to rebuild my own multi year price history for a file with over a hundred different commodities using it. Whether it's still valid and still works are legitimate questions, but Chris might find it an interesting read. For everyone else: don't use my code. https://github.com/sunfish62/NewPriceHistory David T. -------- Original Message -------- From: Derek Atkins <[email protected]> Sent: Thu Jul 01 09:52:35 EDT 2021 To: [email protected] Cc: [email protected] Subject: Re: [GNC] pricehist: a tool to fetch historical prices Hi, Just note that GnuCash (and more generally, the GnuCash team) does not support modifications of the gnucash database outside of GnuCash. Doing so may break your data file, especially as it changes over time. If you're not using the GnuCash APIs to modify your data file, you "void the warranty". YMMV. -derek On Thu, July 1, 2021 9:45 am, Chris Berkhout wrote: > Hi all, > > I've written a command-line tool to fetch daily historical prices. It > currently supports 5 sources of data and will generate output in 4 > formats, > including SQL for a GnuCash database. > > https://gitlab.com/chrisberkhout/pricehist > > Fetching prices and immediately applying them to a GnuCash database is > done > as in the following examples: > > pricehist fetch ecb EUR/USD -s 2021-06-25 -o gnucash-sql | sqlite3 > Accounts.gnucashpricehist fetch ecb EUR/USD -s 2021-06-25 -o > gnucash-sql | mysql -u username -p -D databasenamepricehist fetch ecb > EUR/USD -s 2021-06-25 -o gnucash-sql | psql -U username -d > databasename -v ON_ERROR_STOP=1 > > I discuss some details of the generated SQL in the source code: > > https://gitlab.com/chrisberkhout/pricehist/-/blob/master/src/pricehist/outputs/gnucashsql.py > > As far as I am aware GnuCash's built-in price fetching is for current > prices only. The wiki documents wrapper scripts for the Finance::QuoteHist > Perl module, and the Piecash library has a Commodity.update_prices method > for fetching historical prices, but I hope that pricehist will make > fetching historical prices easy for GnuCash users who don't want to write > their own code for it. > > If pricehist might be useful for you please try it and let me know what > you > think. I'm still improving error handling and some other things but the > main functionality is done. > > Cheers, > Chris > _______________________________________________ > gnucash-user mailing list > [email protected] > To update your subscription preferences or to unsubscribe: > https://lists.gnucash.org/mailman/listinfo/gnucash-user > If you are using Nabble or Gmane, please see > https://wiki.gnucash.org/wiki/Mailing_Lists for more information. > ----- > Please remember to CC this list on all your replies. > You can do this by using Reply-To-List or Reply-All. > -- Derek Atkins 617-623-3745 [email protected] www.ihtfp.com Computer and Internet Security Consultant _______________________________________________ gnucash-user mailing list [email protected] To update your subscription preferences or to unsubscribe: https://lists.gnucash.org/mailman/listinfo/gnucash-user If you are using Nabble or Gmane, please see https://wiki.gnucash.org/wiki/Mailing_Lists for more information. ----- 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 [email protected] To update your subscription preferences or to unsubscribe: https://lists.gnucash.org/mailman/listinfo/gnucash-user If you are using Nabble or Gmane, please see https://wiki.gnucash.org/wiki/Mailing_Lists for more information. ----- Please remember to CC this list on all your replies. You can do this by using Reply-To-List or Reply-All.
