Investment Performance Report Error

Mike Bray 's Avatar

Mike Bray

20 Jul, 2018 05:05 AM

I have just run an Investment Performance Report without changing any of the selection parameters and got a wrong value. I have two investments in FP CRUX European Special Situations. One in an ISA and one in a Fund and Share account. Both entries are showing in the ISA and the ISA account entry is duplicated thus throwing off the investment report. See enclosed screen shot.

Moneydance version 2017.7.1 (1671)
OS: Windows 8.1

The Portfolio screen shows the correct values (see screen shots)

  1. 1 Posted by derekkent23 on 20 Jul, 2018 09:05 AM

    derekkent23's Avatar

    Hi Mike

    I see your issue.

    Just taken a look at my INVESTMENT PERFORMANCE report, not one I use, but it looks OK. I am running 2017.8(1688).

    I wonder if its worth clicking on EDIT – RESET in the INVESTMENT PERFORMANCE report.

    Also, I note Sean seems to have been doing bug fixes in this area may be worth trying the Preview build 2017.8(1688)

    Hope this helps

  2. 2 Posted by Mike Bray on 20 Jul, 2018 09:46 AM

    Mike Bray 's Avatar

    Hi Derek, thanks for the advice, unfortunately same result. Looks like a bug.

  3. 3 Posted by derekkent23 on 20 Jul, 2018 10:04 AM

    derekkent23's Avatar

    Hi Mike

    I hope you get a response from SUPPORT STAFF!!

  4. 4 Posted by sth on 21 Jul, 2018 04:53 PM

    sth's Avatar

    Investment reports and analysis are a weak spot in MD. There are a bunch of bugs in the reports and I think you have found one. I hope Sean/IK respond and fix this one. I still get reports where the return is a positive amount of dollars and the IRR (or ROI as they call it, is negative). Maybe MD 2019 will have some good news?

  5. 5 Posted by travelbird2 on 21 Jul, 2018 09:38 PM

    travelbird2's Avatar

    This comment was split into a new discussion: Investment Performance Report Error

    I just came across another bug. When there are split transactions in a cash portion of the account, these transactions are not included so balance way wrong.

    I tracked this down by exporting transactions and then matching them with the register and every single one that has a split is not in the exported transactions.

    The register shows a balance of $0.00 but the report shows (6,200.00). This amount is the exact amount of the split transactions.

    In this case try are transfers from another account with a category assigned, i.e. Dividend paid is transferred to the my checking account at a different brokerage firm. When entered the transaction is an Xfr with the security that paid the dividend to the account at the brokerage with a category of Dividend Income.

    I have hundreds of these kind of transactions as I transferred my data from Quicken.

  6. 6 Posted by sth on 22 Jul, 2018 12:25 AM

    sth's Avatar

    Steven, this needs to be a separate thread. If IK is to have any chance of tracking errors thread hijacking makes that impossible. It is a completely different issue and not related to the thread title. Lets not make IK's job of fixing bugs harder.

  7. 7 Posted by travelbird2 on 23 Jul, 2018 03:07 PM

    travelbird2's Avatar

    I already did that. I realized that I needed to make a separate thread right after I hit submit. Sorry.

  8. Support Staff 8 Posted by Sean Reilly on 15 Aug, 2018 10:15 PM

    Sean Reilly's Avatar

    Hi Mike,

    I just checked out the code and it looks like the transactions may have been out of order when they were grouped by account+security, which made the security that was common between those two investment accounts have extra rows in the wrong account's section. I've tweaked the transaction sorting to see if that might be the problem and build 1692 should be available on the preview site in a short while with that change. If that doesn't fix it I'll take a deeper look.

    Thanks!

    Sean Reilly
    Developer, The Infinite Kind
    http://infinitekind.com

  9. 9 Posted by Mike Bray on 21 Aug, 2018 03:18 PM

    Mike Bray 's Avatar

    Sean preview 1693 has completely broken this report. It now creates several entries of the same security and several entries for the same Investment Account. See enclosed 'performance report.jpg and compare with performance.jpg

    Mike

  10. 10 Posted by Mike Bray on 22 Aug, 2018 05:03 AM

    Mike Bray 's Avatar

    Sean, preview 1694 still the same as 1693

  11. 11 Posted by Mike Bray on 01 Oct, 2018 12:12 PM

    Mike Bray 's Avatar

    Sean

    I have decompiled the class that creates the result and debugged it. I now have it working. The issue is in the Comparator for building the transactions. It does not take into account the owning investment account.

    You need the following code:

         Comparator<AbstractTxn> comparator = new Comparator<AbstractTxn>() {
    
                @Override
                public int compare(AbstractTxn t1, AbstractTxn t2) {
    // new code
                    Account t1Acct = t1.getParentTxn().getAccount();
                    Account t2Acct = t2.getParentTxn().getAccount();
                    if (t1Acct == null
                            || t1Acct.getAccountType() != Account.AccountType.INVESTMENT
                            || t1.getAccount().getAccountType() != Account.AccountType.SECURITY)
                        return 0;
                    if (t2Acct == null
                            || t2Acct.getAccountType() != Account.AccountType.INVESTMENT
                            || t2.getAccount().getAccountType() != Account.AccountType.SECURITY)
                        return 0;
                    int cmp = AccountUtil.compareAccountNames(t1Acct, t2Acct);
                    if (cmp !=0) 
                        return cmp; 
    // end of new code
    

    After this it all worked. Basically the sort was mixing transactions from the same security but different investment accounts.

  12. Support Staff 12 Posted by Sean Reilly on 19 Oct, 2018 09:30 PM

    Sean Reilly's Avatar

    Hi Mike,
    Sorry for the delay in following up on this, but would the following code also solve the problem?

    // sort by security account
    int cmp = AccountUtil.ACCOUNT_TYPE_NAME_COMPARATOR.compare(t1.getAccount(), t2.getAccount());
    if(cmp!=0) return cmp;
    

    Thanks!

    Sean Reilly
    Developer, The Infinite Kind
    http://infinitekind.com

  13. 13 Posted by Mike Bray on 20 Oct, 2018 08:34 AM

    Mike Bray 's Avatar

    Hi Sean

    That looks like it will work. All that needs to happen is that the
    Investment Account Name must be the first field that is sorted, followed
    by the Security Name.

    Regards
    Mike

  14. 14 Posted by Mike Bray on 24 Oct, 2018 08:41 AM

    Mike Bray 's Avatar

    I see from the text of preview build 1704 you have fixed the problem. I have just downloaded this build and tried it. NO CHANGE!!!.

    I have decompiled the class and you seem to have removed the comparator code in favour of the CapitalGainsReport TxnSortComparator. This has not worked.

    This is the code that works:

    
        private List<AbstractTxn> buildTransactionList(AccountFilter accountFilter) {
            TransactionSet txnSet;
            ArrayList<AbstractTxn> txns = new ArrayList<AbstractTxn>();
            TransactionSet transactionSet = txnSet = this.book.getTransactionSet();
            synchronized (transactionSet) {
                for (AbstractTxn txn : txnSet.iterableTxns()) {
                    if (txn.getAccount().getAccountType() != Account.AccountType.SECURITY
                            || !accountFilter.filter(txn.getAccount()))
                        continue;
                    txns.add(txn);
                }
            }
            Comparator<AbstractTxn> comparator = new Comparator<AbstractTxn>() {
    
                @Override
                public int compare(AbstractTxn t1, AbstractTxn t2) {
                    Account t1Acct = t1.getParentTxn().getAccount();
                    Account t2Acct = t2.getParentTxn().getAccount();
                    if (t1Acct == null
                            || t1Acct.getAccountType() != Account.AccountType.INVESTMENT
                            || t1.getAccount().getAccountType() != Account.AccountType.SECURITY)
                        return 0;
                    if (t2Acct == null
                            || t2Acct.getAccountType() != Account.AccountType.INVESTMENT
                            || t2.getAccount().getAccountType() != Account.AccountType.SECURITY)
                        return 0;
                    int cmp = AccountUtil.compareAccountNames(t1Acct, t2Acct);
                    if (cmp !=0) 
                        return cmp;
                    cmp = AccountUtil.compareAccountNames(
                            t1.getAccount(), t2.getAccount());
                    if (cmp != 0) {
                        return cmp;
                    }
                    cmp = t1.getDateInt() - t2.getDateInt();
                    if (cmp != 0) {
                        return cmp;
                    }
                    if ("|^Unreal^|".equals(t1.getDescription())) {
                        return 1;
                    }
                    if ("|^Unreal^|".equals(t2.getDescription())) {
                        return -1;
                    }
                    long v1 = t1.getValue();
                    long v2 = t2.getValue();
                    if (v1 < 0L && v2 < 0L || v1 >= 0L && v2 >= 0L) {
                        long diff = t1.getValue() - t2.getValue();
                        if (diff < 0L) {
                            return -1;
                        }
                        if (diff > 0L) {
                            return 1;
                        }
                        return 0;
                    }
                    if (v1 < 0L && v2 >= 0L) {
                        return 1;
                    }
                    if (v1 >= 0L && v2 < 0L) {
                        return -1;
                    }
                    return 0;
                }
            };
            Collections.sort(txns, comparator);
            return txns;
        }
    

    This is what I found:

            private List<AbstractTxn> buildTransactionList(AccountFilter accountFilter)
            {
            List<AbstractTxn> txns = new ArrayList();
             com.infinitekind.moneydance.model.TransactionSet txnSet = 
             this.book.getTransactionSet();
              synchronized (txnSet) {
               for (AbstractTxn txn : txnSet.iterableTxns())
             {
             if ((txn.getAccount().getAccountType() == Account.AccountType.SECURITY) 
         && 
               (accountFilter.filter(txn.getAccount())))
             {
     
               txns.add(txn);
             }
           }
         }
         
            java.util.Comparator<AbstractTxn> comparator = new 
        CapitalGainsReport.TxnSortComparator();
           java.util.Collections.sort(txns, comparator);
         
           return txns;
         }
     ```
    Mike
    
  15. Support Staff 15 Posted by Sean Reilly on 24 Oct, 2018 12:26 PM

    Sean Reilly's Avatar

    Update: it turns out that this issue was something specific to Mike's file and not related to the moneydance code. We've resolved it with a python script, so I'll close this thread.

    Thanks!

    Sean Reilly
    Developer, The Infinite Kind
    http://infinitekind.com

  16. Sean Reilly closed this discussion on 24 Oct, 2018 12:26 PM.

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