Re: [GNC] Scripted price editing and adding
Thanks to all for the inputs and suggestions. It sounds like I could make this work with a number of different paths, but I'll follow the "read, but don't write" suggestion and defer more of the analysis to the post-reading side and rely less on things like the built-in net worth time plot in Gnucash. I'd hate to end up in a situation where I realize I messed something up somewhere down the road and have to backtrack my save file to old backups. Best, Ray On Fri, Jan 17, 2020 at 6:53 PM Adrien Monteleone < adrien.montele...@lusfiber.net> wrote: > If I recall, the general advice is you can read, but don’t write. > > GnuCash is not yet a true database app. (that is a long term goal) Until > then, writing could be potentially very destructive. > > There are some projects out there designed specifically to query an sqlite > backend of GnuCash for custom reporting. (PieCash comes to mind) I’m not > sure about MySQL or XML. > > GnuCash has Python bindings so you could roll your own solution. But even > then, I think they are query only. > > > Regards, > Adrien > > > On Jan 17, 2020 w3d17, at 8:34 PM, Peter West 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 > > > ___ > gnucash-user mailing list > gnucash-user@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@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.
Re: [GNC] Scripted price editing and adding
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 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 p...@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 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 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@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@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@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.
Re: [GNC] Scripted price editing and adding
If I recall, the general advice is you can read, but don’t write. GnuCash is not yet a true database app. (that is a long term goal) Until then, writing could be potentially very destructive. There are some projects out there designed specifically to query an sqlite backend of GnuCash for custom reporting. (PieCash comes to mind) I’m not sure about MySQL or XML. GnuCash has Python bindings so you could roll your own solution. But even then, I think they are query only. Regards, Adrien > On Jan 17, 2020 w3d17, at 8:34 PM, Peter West 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 ___ gnucash-user mailing list gnucash-user@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.
Re: [GNC] Scripted price editing and adding
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 p...@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 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 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@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@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.
Re: [GNC] Scripted price editing and adding
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 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@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.
[GNC] Scripted price editing and adding
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 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 gnucash-user@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.