[GNC] pricehist: a tool to fetch historical prices

Chris Berkhout chrisberkhout at gmail.com
Thu Jul 1 09:45:05 EDT 2021


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


More information about the gnucash-user mailing list