[GNC] Scripted price editing and adding

D sunfish62 at yahoo.com
Fri Jan 17 22:17:52 EST 2020


A few versions back, I pieced together a Perl script that rebuilt the price history for a Gnucash SQL file, replacing the existing history table with monthly prices for the duration that a given commodity was held. It worked fine for me, and cleaned up years of erratic pricing info, although it did mess with the data directly, which is frowned upon in these circles. Unfortunately, it used the Yahoo! price source, which is no longer available. The code is available on github. 

David T.

On January 18, 2020, at 8:05 AM, Peter West <pbw at pbw.id.au> wrote:

I’m curious about using sql scripts for read and update operations on Gnucash data when that data is maintained in such a database. For XML, similar things could be accomplished using XSLT or XQuery.

Has anything along these lines been done?

--
Peter West
pbw at pbw.id.au
Moved with pity, he stretched out his hand and touched him and said to him, “I will; be clean.”

> On 18 Jan 2020, at 10:33 am, Jon Schewe <jpschewe at mtu.net> wrote:
> 
> On 1/14/20 10:28 PM, Raymond Smith wrote:
>> Hi, Gnucash list.
>> 
>> I'm interested in using a script to add and edit prices in my Gnucash file.
>> For example, I'd like to
>> (a) loop over a file containing historical price data and add prices for
>> dates where the price is missing because I didn't do a quote retrieval in
>> Gnucash that day
>> (b) loop over the prices I have of one security and add prices for call
>> options using max(0, security price - strike price).
>> I would prefer working in Python if possible, and I'm looking for guidance
>> on the right approach.
>> 
>> I've seen there are some Python bindings and also the piecash library, but
>> it's not clear to me how well maintained or supported either is right now.
>> I found relatively little documentation on the Python bindings (
>> https://wiki.gnucash.org/wiki/Python_Bindings). Piecash looks very nice,
>> and I was able to set up a simple example where I added a price using it.
>> But, it currently has a very minor issue (
>> https://github.com/sdementen/piecash/issues/126) that prevented it from
>> running on my recent gnucash save files without a simple fix. Not a big
>> deal to do that, but I'd like to avoid tying myself to a library that
>> stalls while Gnucash and my save files continue to evolve.
>> 
>> Another option I've thought about is to parse xml files using something
>> like Python's xml library. That seems reasonably straightforward at first
>> glance, but perhaps there are some things I should be aware of that I'm
>> missing that would make this a bad idea? One question that has already come
>> up is how to manage guid's of the prices. Can they be any string of the
>> appropriate length as long as each is unique within the file? I tried a
>> super simple test file where I copied one <price></price> block and changed
>> the date, price, and guid, then re-opened the file, and it seemed to work,
>> but I'm not sure if that's dangerous.
> Take a look at this post that I put up last month https://lists.gnucash.org/pipermail/gnucash-user/2019-December/088313.html
> This has a reference to a script that I wrote to get my price quotes on a regular basis when the normal mechanism wasn't working. The python bindings seem to work fine.
> 
> Jon
> 
> -- 
> http://mtu.net/~jpschewe
> 
> _______________________________________________
> gnucash-user mailing list
> gnucash-user at gnucash.org
> 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
gnucash-user at gnucash.org
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.


More information about the gnucash-user mailing list