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. Many thanks for any guidance or insights you may have. Ray _______________________________________________ gnucash-user mailing list email@example.com 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.