StockGlance2020 - Python script to display and extract the totals of stock/fund unit qty balances by security

For anyone that wants it, Python script to extract / total stock / unit qty balances by Security (as MD doesn’t have a report to do this). Original Credit to @jameslarus and waynelloydsmith as I took StockGlance as a base).

For example: if I have share/security "Company X" in 3 different ac counts - e.g. 100, 300, 500, then this script will tell you that you have 900 of this security. MD reports do not do this. The report also shows you a lot more, deals with currency, totals, and can show cash balances.

It's quite clever with lots of user parameters and filters. Let me know of any issues...

  1. Stuart Beesley - JUST A FELLOW USER closed this discussion on 24 Sep, 2020 05:16 PM.

  2. Stuart Beesley - JUST A FELLOW USER re-opened this discussion on 26 Sep, 2020 10:14 AM

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

    Stuart Beesley - JUST A FELLOW USER's Avatar

    Small bug fix (exported filename check). Version 3 here.

  4. 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

  5. 3 Posted by Stuart Beesley ... on 27 Sep, 2020 06:48 PM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    V3c with extra features

  6. 4 Posted by Stuart Beesley ... on 28 Sep, 2020 10:17 PM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    Version 3d (last one) - some minor fixes/tweaks/enhancements

  7. 5 Posted by davidvernonlong on 29 Sep, 2020 06:19 PM

    davidvernonlong's Avatar

    Looks a bit scary as I would probably mess up running the script etc. Look forward to it seeing it as an extension or incorporated into the standard reporting.

  8. 6 Posted by Stuart Beesley ... on 29 Sep, 2020 06:31 PM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    Not scary at all. It can’t do any harm as it’s read only.
    Just load MD as normal.
    Main menu>> view menu
    Choose Show MoneyBot Console
    Click open script
    Choose my script file you downloaded
    Click run.

    That’s it

    If you're on a Mac and get a 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.

    You will then get a nice screen display up of the stocks and balances.

    Regards Stuart

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

    

  9. 7 Posted by Stuart Beesley ... on 29 Sep, 2020 06:35 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

  10. 8 Posted by davidvernonlong on 29 Sep, 2020 06:53 PM

    davidvernonlong's Avatar

    Thanks. Not scared anymore! It worked fine, thanks.
    Best
    David

  11. 9 Posted by Stuart Beesley ... on 29 Sep, 2020 07:08 PM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    Excellent!

    Regards Stuart

    On 29 Sep 2020, at 19:53, davidvernonlong <[email blocked]> wrote:

    

  12. 10 Posted by couten on 19 Oct, 2020 08:48 AM

    couten's Avatar

    Tks for this script ... Do you think it would be possible to have the option to run so the result is expanded, ie if a security is in 3 accounts, having 3 different lines, one per account ? Tks alot !

    I cannot understand why this is not proposed as a standard report in MD ... which is just swapping 1st and 2d column in investment reports ....

  13. 11 Posted by Stuart Beesley ... on 19 Oct, 2020 09:41 AM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    Hi, but then isn’t this just what the Portfolio report does….?

    SCB

  14. 12 Posted by Cyril Couten on 19 Oct, 2020 11:54 AM

    Cyril Couten's Avatar

    not really ... the hierarchy is account, then security ...
    here I am suggestion the reverse having security by account ...
    The script does it well but aggregates the total amount by security without
    the breakdown.
    To achieve this, running portfolio report, copy into excel, then taking out
    all unnecessary lines, change commas etc ... not a very quick process.

    All portfolio SW propose either to view by account/security and the
    reverse. Cannot understand why MD does not propose it ... Tks !
    _______________________________
    Cyril COUTEN
    Mobile : +33 6 18 40 80 65

  15. 13 Posted by Stuart Beesley ... on 19 Oct, 2020 12:10 PM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    Yes, I get it.. I’ll think about it. The whole script is set up to accumulate by Security. Also, how would you display security qty totals in this view?

  16. 14 Posted by davidvernonlong on 19 Oct, 2020 12:55 PM

    davidvernonlong's Avatar

    I do it by editing the portfolio report to select only the security I want, but the I do not get quantity total

  17. 15 Posted by Cyril Couten on 19 Oct, 2020 01:12 PM

    Cyril Couten's Avatar

    Yes but then you have to "edit" the report & select in the list as many
    times as the security is in any account ...
    The "search" facility at the top right does not work ... unfortunately ...
    as this is could be an easier way.
    In the end, having the report for all securities with the breakdown by
    account is really what is needed ...(This was available in MONEY and
    QUICKEN).
    Does it make sense ?
    Tks.
    _______________________________
    Cyril COUTEN
    Mobile : +33 6 18 40 80 65

  18. 16 Posted by davidvernonlong on 19 Oct, 2020 01:27 PM

    davidvernonlong's Avatar

    Hi,

     

    Yes, it worked like that in Quicken and Money, having made the transition twice now. Agreed my method is a long winded way of doing it.

    Ultimately we need all the reports, including Investment performance, on the basis you suggest, as well as the ability to transfer securities between accounts without dummy sales and purchase transactions which screws up the reporting, but guess that’s beyond the scope of this script, but is at least a stopgap until a new version.

  19. 17 Posted by Cyril Couten on 19 Oct, 2020 01:32 PM

    Cyril Couten's Avatar

    Understand. May be simply have, meanwhile, a specific report with this
    sequence security/account having cash by account or not...
    If we agree that it is needed, this is already a good step. Understand
    this may take a while until this is done.

    Hope this helps. Tks.
    _______________________________
    Cyril COUTEN
    Mobile : +33 6 18 40 80 65

  20. 18 Posted by Stuart Beesley ... on 20 Oct, 2020 09:19 AM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    As requested, a version to split Securities by Account. NOTE: This is safe to run, but is version 4b (beta). I would value your comments: Download here:

    https://github.com/yogi1967/MoneyDancePythonScripts/blob/dev/StockGlance2020.py <https://github.com/yogi1967/MoneyDancePythonScripts/blob/dev/StockGlance2020.py>
    StockGlance2020.py <https://github.com/yogi1967/MoneyDancePythonScripts/blob/dev/StockGlance2020.py>

    The display is more ‘messy’, but difficult to fix that….

    Let me know how you get on? I would value feedback.

    Stuart

  21. 19 Posted by Cyril Couten on 20 Oct, 2020 09:57 AM

    Cyril Couten's Avatar

    Great ! As such this is a real progress !

    A few comments :

    1/ Adding cost/unit, total cost , capital gain (current value - total cost)
    would be a great plus, ie see +/- capital gains for a same stock in the
    various accounts
    2/ Order of symbols : what is the logic ?
    3/ If one can sort the whole set by total value ... I suspect this is more
    difficult ?
    4/ The loading into csv comes first before displaying ... which was the
    case in previous script (this is better to visualize to decide to file
    after).
    5/ In the menu, eventually add choice to have total or not (export to excel
    as a database allows to make a pivot table without filtering/selecting)
    6/ Save choices for the menu (to avoid to retype Y or N depending on
    choices) !

    Tks a lot.
    _______________________________
    Cyril COUTEN
    Mobile : +33 6 18 40 80 65

    <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
    Garanti
    sans virus. www.avast.com
    <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
    <#m_8423827681192744572_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

  22. 20 Posted by Stuart Beesley ... on 20 Oct, 2020 10:09 AM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    Just quickly. Point:
    1/ I can pull / display the MD cost basis calculation (as displayed on the portfolio screen) and then also (value - cost basis = gain) if this is what you mean?
    2/ the sort is by Security Name (this was ticker and can be either)
    3/ Not really. If you don’t split then you can sort however you want by clicking on columns, but it won’t work with splits.... but you can do this in excel.
    4/ not sure I understand. The menu already asks if you want to export or not. The display then comes up first and then the export last.
    6/ for now, you can just edit the script and change the parameter defaults in the lines 131-145.

    What’s your opinion on the display format now?

    Regards Stuart

  23. 21 Posted by Cyril Couten on 20 Oct, 2020 02:38 PM

    Cyril Couten's Avatar

    pls see below ... tks.
    _______________________________
    Cyril COUTEN
    Mobile : +33 6 18 40 80 65

  24. 22 Posted by Stuart Beesley ... on 20 Oct, 2020 02:56 PM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    No comments…? You have to reply above the ===== line… S

  25. 23 Posted by Cyril Couten on 20 Oct, 2020 03:08 PM

    Cyril Couten's Avatar

    OK let me copy paste ... here you go ...

    1/ I can pull / display the MD cost basis calculation (as displayed on the
    portfolio screen) and then also (value - cost basis = gain) if this is what
    you mean? YES
    2/ the sort is by Security Name (this was ticker and can be either) either
    one is OK, can we sort by amount of total security ?
    3/ Not really. If you don’t split then you can sort however you want by
    clicking on columns, but it won’t work with splits.... but you can do this
    in excel. OK
    4/ not sure I understand. The menu already asks if you want to export or
    not. The display then comes up first and then the export last. The display
    shows after filing the csv (before display showed first, which is better)
    6/ for now, you can just edit the script and change the parameter defaults
    in the lines 131-145. OK

    What’s your opinion on the display format now? did you send another file ?
    _______________________________
    Cyril COUTEN
    Mobile : +33 6 18 40 80 65

    <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
    Garanti
    sans virus. www.avast.com
    <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
    <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

  26. 24 Posted by Stuart Beesley ... on 20 Oct, 2020 06:48 PM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    Hi, Sorry I disagree. On point four… The display always come first and the program then waits for you to close the display window… It does not create the CSV file until the display is closed… If you think otherwise then something is going wrong. Pls run with debug on and you will see it waiting for the JFrame to close before it creates the CSV file?

  27. 25 Posted by Cyril Couten on 20 Oct, 2020 09:23 PM

    Cyril Couten's Avatar

    I just tried again : it asks for a place to store the extract, and then
    after it does the display...
    Strange as yesterday it was the order you mention ...
    Anyway this is not important ...
    I will rerun tomorrow ...

    Tks
    _______________________________
    Cyril COUTEN
    Mobile : +33 6 18 40 80 65

  28. 26 Posted by Stuart Beesley ... on 21 Oct, 2020 01:37 PM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    Hi. Ok I get what you mean now. Yes it asks for the file location upfront and then it displays. BUT it does not write the csv file until after the display window is closed.

    Regards Stuart

  29. 27 Posted by Cyril Couten on 21 Oct, 2020 02:43 PM

    Cyril Couten's Avatar

    Super. Do you think yuu will send an updated script as I have the on
    before my suggestions ... ? Tks.
    _______________________________
    Cyril COUTEN
    Mobile : +33 6 18 40 80 65

    <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
    Garanti
    sans virus. www.avast.com
    <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
    <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

  30. 28 Posted by Stuart Beesley ... on 21 Oct, 2020 06:45 PM

    Stuart Beesley - JUST A FELLOW USER's Avatar

    Updated script now available at the development link I sent before. I haven’t had much time today. This includes the saving parameters between sessions…. Let me know if it works OK for you. Thanks

  31. 29 Posted by Cyril Couten on 21 Oct, 2020 08:56 PM

    Cyril Couten's Avatar

    Yes, parameter do stay as in previous run ! Tks
    _______________________________
    Cyril COUTEN
    Mobile : +33 6 18 40 80 65

  32. 30 Posted by derekkent23 on 22 Oct, 2020 08:45 AM

    derekkent23's Avatar

    Hi Stuart

    Probably missing something.

    StockGlance2020_v4.py works.

    StockGlance2020.py Version 4c of StockGlance2020.py
    From https://github.com/yogi1967/MoneyDancePythonScripts/find/dev
    Is this the correct link?
    Does not work on windows 10 with MD 2021(2006). I get:

    SyntaxError: Non-ASCII character in file 'C:\Users\derek\OneDrive\MONEYDANCE\Script to display and CSV Export Security Totals\StockGlance2020.py', but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

    Thanks

Comments are currently closed for this discussion. You can start a new one.

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