StockGlance2020: Script to total the quantity of stocks/shares held across several / all Accounts

Several people have asked about totalling the qty of securities held across MD Accounts. This script handles currency and asks the user for selection parameters, shows on screen, and will also export to a file.

https://infinitekind.tenderapp.com/discussions/moneydance-development/3063-stockglance2020-python-script-to-display-and-extract-the-totals-of-stockfund-unit-qty-balances-by-security

NOTE: I am a user, not support.

Let me know of any problems?

  1. 1 Posted by Stuart Beesley ... on 26 Sep, 2020 10:15 AM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    Small bug fix on export filename check. Version 3 here

  2. 2 Posted by Stuart Beesley ... on 26 Sep, 2020 10:54 AM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    version 3b - Changed display to tell user when file is generated and to prevent access to .moneydance system folder

  3. 3 Posted by derekkent23 on 27 Sep, 2020 03:08 PM

    derekkent23's Avatar

    Hi Stuart

    Your script, great work.

    Two suggestion. When INCLUDE CASH BALANCE FOR EACH ACCOUNT ? is Y add to display/CSV export a total for Securities plus Cash “Total: Investment Accounts”. Perhaps change the wording Totals: to “Total: Securities”:

  4. 4 Posted by Stuart Beesley ... on 27 Sep, 2020 03:11 PM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    Thanks for suggestions. I was tempted to add the totals together but it can be misleading - especially if the user has added filters as cash balances don’t actually have any bearing on securities and the total would only be valid if all the securities for an account were chosen??

  5. 5 Posted by derekkent23 on 27 Sep, 2020 04:51 PM

    derekkent23's Avatar

    Hi Stuart

    The Total: Investment Accounts would only be present if INCLUDE CASH BALANCE FOR EACH ACCOUNT ? was Y and be the sum of the cash Bal/Acct, plus the values of the securities displaced as a result of other filter settings. If you think others would find that confusing OK, its still a great script, I can use my calculator to do the final math.
    Thanks.

  6. 6 Posted by Stuart Beesley ... on 27 Sep, 2020 06:00 PM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    Hi, and therein lies the problem… The Cash Balance is not relative to the security… So if I select a security using a filter, then the cash balance is still the same account’s total cash balance. Hence, the maths would be nonsense. However I could do the maths if ALL securities for an account are selected perhaps?

  7. 7 Posted by derekkent23 on 27 Sep, 2020 06:30 PM

    derekkent23's Avatar

    Hi, that makes sense.

  8. 8 Posted by Stuart Beesley ... on 27 Sep, 2020 06:47 PM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    OK, v3c added to total securities + cash balances where certain ALL filters are selected... Have fun! Let me know if this works OK for you?

  9. 9 Posted by derekkent23 on 27 Sep, 2020 09:42 PM

    derekkent23's Avatar

    Hi Stuart

    That great.

    I am in the UK, so in sterling. I had expected the TOTAL Securities+Cash Bal: to be equal to the Current Balance Investment Accounts on the MD Summary window. However, first ends in 12 the second in 10.66 Looking more closely MD rounds each security price in pence to 2 decimal places and the script rounds them to pounds before adding them together. No big deal.

    Thank for your great work.

  10. 10 Posted by Stuart Beesley ... on 27 Sep, 2020 10:22 PM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    I presume it’s no more than a £1(ish) out in total? Yes I’m aware of the rounding issue...

    Regards Stuart

    On 27 Sep 2020, at 22:42, derekkent23 <[email blocked]> wrote:

    

  11. 11 Posted by derekkent23 on 28 Sep, 2020 07:04 AM

    derekkent23's Avatar

    Hi Stuart

    Yes, just a small error. In my case the difference was £1.34

  12. 12 Posted by Stuart Beesley ... on 28 Sep, 2020 05:09 PM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    OK, (the rounding was bugging me anyway/too), so I have fixed that, and made some other tweaks to enhance the display. Also added functionality to cope with non decimal point locales (I hope).... Version 3d attached. Would value feedback. Thanks

  13. 13 Posted by derekkent23 on 28 Sep, 2020 05:53 PM

    derekkent23's Avatar

    Hi Stuart.

    When I run StockGlance2020_v3d.py under windows 10 MD2020.2(1929) I get a error, see screen shot. Earlier versions still run OK.

  14. 14 Posted by Stuart Beesley ... on 28 Sep, 2020 06:00 PM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    Oops! My bad! I was running in Python Moneybot console where I had already imported this module from another program. It seems to remember these between runs. So it didn't fail. Now fixed. See revised/attached - thanks

  15. 15 Posted by derekkent23 on 28 Sep, 2020 08:01 PM

    derekkent23's Avatar

    Hi Stuart.

    That work for me.
    Great work.

    Have Fun, Stay Safe.

  16. 16 Posted by Stuart Beesley ... on 29 Sep, 2020 03:59 PM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    Hi Derek, I hope you don't mind me asking. I decided I wasn't happy with the file creation method and have changed that - to better cope with special characters and locales. It all seems to be working OK. However, I don't have access to Windows (only Mac). I wonder if you wouldn't mind running this version to check it's still OK for you - and also export to CSV and check it opens OK etc in Excel for you on Windows? Thanks
    Version 4 (hopefully final) attached

  17. 17 Posted by derekkent23 on 29 Sep, 2020 06:23 PM

    derekkent23's Avatar

    Hi Stuart

    No Problem, any time.
    Tested on windows 10 with excel and Linux Feren OS with LibreOffice.
    All works great.

    Have Fun, Stay Safe.

  18. 18 Posted by Stuart Beesley ... on 29 Sep, 2020 06:32 PM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    Excellent. Thanks.

    Regards Stuart

    On 29 Sep 2020, at 19:23, derekkent23 <[email blocked]> wrote:

    

  19. 19 Posted by Stuart Beesley ... on 29 Sep, 2020 06:36 PM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    Final version 4 of Stock Glance 2020 script. Tweaks and enhancements. To run:
    Just load MoneyDance as normal.
    From within MoneyDance: Main menu>> View menu
    Choose Show MoneyBot Console
    Click Open script
    Choose my script file you just downloaded
    Click Run.

    That’s it

    If you're on a Mac and get a xxx.dylib cannot be opened message. Just click cancel. It’s a harmless MD bug that they need to get rid of sometime. It’s nothing to do with the script. So ignore that.

    PS - It can’t do any harm as it’s read only.

    Have fun

  20. 20 Posted by Stuart Beesley ... on 26 Oct, 2020 09:45 AM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    For completeness version 5 of this script released - attached. The latest can always be found here:
    https://github.com/TheInfiniteKind/moneydance_open/tree/main/python_scripts

    Rollup of v4a to v4h enhancements. Key changes: enhanced filters; enhanced parameters; Parameters now persist between sessions; better rounding; New option to split Securities by Account; Enhanced display, sort, highlighting, formatting, scrolling etc; added cost basis, gain and % fields; enhanced CSV creation, including ability to exclude totals (for Pivot tables). By Stuart Beesley - StuWareSoftSystems - October 2020.

  21. 21 Posted by Stuart Beesley ... on 31 Oct, 2020 12:46 PM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    StockGlance2020 version 5a. Finally found and fixed issue where it fails to create file on some Windows 10 installations (due to system folder access restrictions) .. Attached

  22. 22 Posted by Stuart Beesley ... on 05 Nov, 2020 04:10 PM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    StockGlance2020 version 5c - hopefully the final version. Added parameter to allow user not to round prices... (optional)

  23. 23 Posted by Stuart Beesley ... on 11 Nov, 2020 05:43 PM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    Latest update (v5e)

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Already uploaded files

  • StockGlance2020_v2.py 71.8 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac