Wrong shares balance

bm's Avatar


11 May, 2023 05:37 AM

I'm encountering a strange bug. I have a simple investment account with only 13 entries in it, all of which have BuyXfr as the action. They all have the same Security. Yet, when I go to portfolio view, the number under Shares is way off. I'm fairly sure this happened when the process got stuck and I had to kill it, but I'm not sure how to fix it.

I've had this before and was able to spot the problem at the time, restore an old backup, and then redo the transactions.

  1. 1 Posted by Stuart Beesley ... on 11 May, 2023 06:19 AM

    Stuart Beesley (Mr Toolbox)'s Avatar

    Launch toolbox extension. Does it alert you to a problem?

  2. 2 Posted by bm on 11 May, 2023 06:29 AM

    bm's Avatar

    I actually figured out the problem (though not an easy solution):

    When you do a batch change to move several transactions from one investment account to another, it messes up the share balance and I still don't know how to fix it.

    I have now restored a backup and updated records manually again, but it would be good to fix this bug for the sake of others.

  3. 3 Posted by Stuart Beesley ... on 11 May, 2023 06:33 AM

    Stuart Beesley (Mr Toolbox)'s Avatar

    Me too. What do you mean by:
    “When you do a batch change to move several transactions from one investment account to another”? As std MD does not let you do this?

    What exactly are you doing and can you reproduce the problem?

  4. 4 Posted by bm on 11 May, 2023 06:43 AM

    bm's Avatar

    Yes, I can reproduce the problem... while there is no option for batch change in investment accounts, there is such an option on the other side of the transaction. So for example if investments were purchased (BuyXfr) from a checking account, it is possible to select multiple items and do a batch change to the category, moving them from one investment account to another.

  5. 5 Posted by Stuart Beesley ... on 11 May, 2023 08:41 AM

    Stuart Beesley (Mr Toolbox)'s Avatar

    So. Do you deliberately do that? And does that always break it?

  6. 6 Posted by Stuart Beesley ... on 12 May, 2023 10:39 AM

    Stuart Beesley (Mr Toolbox)'s Avatar

    You are correct....

    • If you select multiple 'the other side' of an Buy/SellXfr transaction from within a non-investment account (E.g. a bank register or the category register) and then use batch change to change the category to anything, then you will royally screw up these investment records....

    But of course, this is a nonsense change anyway and should never be done... You are effectivley asking: on the target of the investment transfer in/out, change the source investment account to be account/category xxx... This will take the investment buy/sell txn out of the investment account and dump it into a category account... What you really want to do in this example, when viewing the other side within the non investment account, is batch change the Account (not the category)... But this is of course very confusing to most people.. You should really only batch change investment transactions from within the actual investment account..

    So is this a bug? It's really an illogical choice made by the user... But I agree this should be blocked.. I will speak to the developer....

  7. 7 Posted by dwg on 12 May, 2023 11:12 AM

    dwg's Avatar

    I think doing this is bound to screw up any way you look at it.

    The initial BuyXfr is a compound transaction you pull money from another account and it buys shares in the investment account but there is a child account involved for the security and the actual purchase. By changing where the funds are going to from the bank account leg (the Xfr part) I do not see it is really going to setup the buy transaction (the Buy part) in the account the funds are moved to and remove them from the old investment account correctly. Batch change has no idea how to do this.

    I have just tried it in a test data set and as expected it does not work as you would want it to. It create orphans that toolbox does detect.

  8. 8 Posted by Stuart Beesley ... on 12 May, 2023 03:40 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    FYI - The latest PREVIEW toolbox will now detect this condition and can fix if required..


    @bm - I suggest you run latest PREVIEW toolbox to ensure you have no other txns in this state... Let me know?

  9. 9 Posted by bm on 12 May, 2023 06:40 PM

    bm's Avatar

    Thanks, Stuart, just a bunch of duplicate securities

  10. 10 Posted by Stuart Beesley ... on 12 May, 2023 06:44 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    To confirm. You did download latest 1059 preview from my site?

    It actually would be great if you could recreate the problem and then prove that toolbox detects and can fix it? TIA

  11. 11 Posted by bm on 12 May, 2023 06:58 PM

    bm's Avatar

    Yes, when I reproduce the issue, and close the duplicate security window, I see a message about fixing non-hierarchical security account transactions.

    I would point out though, if you are interested in the feedback, that a nonsensical user making illogical choices will not be able to figure out how to actually run that fix.

    It looks like installing this extension allows batch change on the investment account transactions to move them to another account? That's what I was trying to achieve to begin with.

  12. 12 Posted by Stuart Beesley ... on 12 May, 2023 07:19 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    ? Toolbox installs a new menu option under extensions called:
    ‘Toolbox: move investment transactions’

    To use it, you select the txns in question and then select the menu option. Have you tried this?

  13. 13 Posted by bm on 12 May, 2023 07:47 PM

    bm's Avatar

    Yes, it seemed to have successfully moved the transaction, though when I tried to move it back, it failed:

    >> 1 TRANSACTIONS WILL BE MOVED (out of 107 in Source Account) <<



    Traceback (most recent call last):
      File "extension(toolbox):toolbox_move_merge_investment_txns.py", line 4469, in move_merge_investment_txns
      File "extension(toolbox):toolbox_move_merge_investment_txns.py", line 4452, in create_totals
    NameError: global name 'CurrencyTable' is not defined
      File "extension(toolbox):toolbox_move_merge_investment_txns.py", line 4840, in <module>
      File "extension(toolbox):toolbox_move_merge_investment_txns.py", line 4482, in move_merge_investment_txns
      File "extension(toolbox):toolbox_move_merge_investment_txns.py", line 478, in dump_sys_error_to_md_console_and_errorlog

  14. 14 Posted by bm on 12 May, 2023 07:52 PM

    bm's Avatar

    btw since you seem to be trying to address some of the gaps in investment accounts... any pointers on support for downloading transactions into them? I have some accounts that allow download, but MD does not accept them

  15. 15 Posted by Stuart Beesley ... on 12 May, 2023 08:11 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    That’s very odd. Can you reproduce? What steps exactly did you follow to cause this? Was this on txns previously ‘repaired’?

  16. 16 Posted by Stuart Beesley ... on 12 May, 2023 08:11 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    Have you tried md+?
    Perhaps mention the accounts and see if anyone else has gotten these working?

  17. 17 Posted by bm on 12 May, 2023 08:16 PM

    bm's Avatar

    Yes, I'm using MD+ and it seems to support Morgan Stanley as well as Ally Investment, neither of which download for me. The error goes something like this:

    There was an error communicating with your financial institution. The details of this error are below.

    Bank Name: Moneydance+
    Account: Ally Investments
    Account Number:

    The error code reported by the server was: 0

    Error type: ITEM_ERROR
    Item ID: JQ19Dq1EXEtaMbaJm45XCXDj3JpnVVFbBDKLb
    Request ID: ztNt0CRxWr75h8Z
    Message: the following products are not supported by this institution: ["investments"]

  18. 18 Posted by bm on 12 May, 2023 08:17 PM

    bm's Avatar

    Not seeing my other reply, so trying again:

    I selected one tx from an investment account, and moved it to another account, leaving everything as default and pressing "I agree". I am now trying to do the same thing and move it back, but it works with neither the published extension, nor today's update.

  19. 19 Posted by Stuart Beesley ... on 12 May, 2023 08:59 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    @bm - CONGRATULATIONS and thank you! You found a bug...! Basically, there was a missing reference to an internal MD class (called CurrencyTable). This is actually loaded/referenced by main toolbox, but not by this extension to the extension... If toolbox has been opened first, then the name would exist within the namespace and this bug would be hidden. But if you launch MD and then just run this move extension from the menu (without launching toolbox), then the name would be missing and the bug exposed.... Strangely, I had actually told this line of code before not to flag a warning on compile, and I expect that I could not see the difference between "currencyTable" and "CurrencyTable" at the time, when in fact the code was working for me.... So, thanks - a little bug'ette fixed..

    PREVIEW has been updated on my site....

  20. 20 Posted by bm on 12 May, 2023 10:18 PM

    bm's Avatar

    Great, thanks, seems to have worked... did not try the negative (successful) use case, but worked fine launching and moving the tx back.

    I'll open another thread for MD+ download to investment accounts. Given that it doesn't work for any account I have, and considering the gaps in investment account support in general, I had assumed it didn't work for anyone, but maybe there is hope there.

  21. System closed this discussion on 11 Aug, 2023 10:20 PM.

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

Keyboard shortcuts


? 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