Report to show Security's dividend history (per share)

Stuart Beesley (Mr Toolbox)'s Avatar

Stuart Beesley (Mr Toolbox)

20 Feb, 2025 04:42 AM

[Question raised by @he] Is there anywhere in MD that captures dividend amount per share? My objective is to see dividend history (per share) independent of shares owned. I'm not seeking the total amount which is calculated by multiplying dividend amount by shares held, I know that's already available. I'm seeking just the dividend amount per share, preferably over time. Is this possible?

[Response by @dwg] You do not enter it at all, and I'm not aware of Moneydance calculating it. Strictly speaking having an action type of Div does not necessarily mean it is a dividend. The action type just determined how a transaction is to be processed by Moneydance.

[Response by @he] @dwg, you're right, a security's dividend amount is not calculated within MD. It's either entered manually as the total dividend amount or downloaded from the brokerage. To me, the distributed dividend per share is valuable information. Can it not be calculated in a report based on the dividend amount and number of shares owned as of that date? Mathematically, it would be something like: Dividend share amount = Total dividend amount (downloaded or entered manually) / number of shares owned as of dividend date.

  1. 1 Posted by Stuart Beesley ... on 20 Feb, 2025 04:47 AM

    Stuart Beesley (Mr Toolbox)'s Avatar

    Great question... As mentioned, this is a bit tricky as the source information is not entered. I see a couple of issues, but primarily this:

    The DIV transaction is not necessarily entered on the same date as the 'record date' (the date a share qualifies for a divvy). As such, if the share balance moves between the record date and the ex div date, then the backwards calculation from divvy amount / qty held will be wrong.. So at best, this is an attempt at a calculation (with risk).

    Anyway, here is a first shot at a script to extract this... Let me know how it works, and perhaps report issues you see... If it becomes 'good enough' perhaps we can turn it into a 'proper' report.

    ticker="SMIN"
    from com.infinitekind.moneydance.model import ParentTxn, Account, InvestFields, InvestTxnType, AccountUtil
    from com.infinitekind.util import StringUtils
    md=moneydance
    book=moneydance_data
    ct=book.getCurrencies()
    base=ct.getBaseType()
    fmt=moneydance.getPreferences().getShortDateFormatter()
    security=ct.getCurrencyByTickerSymbol(ticker)
    if security is None: raise Exception("Ticker '%s' not found - aborting" %(ticker))
    print "Found Security: %s" %(security)
    fields=InvestFields()
    tSet=book.getTransactionSet()
    txns=tSet.iterableTxns()
    print ".. analysing txns...:"
    foundTxns=[]
    for txn in txns:
     if not isinstance(txn, ParentTxn): continue
     pAcct=txn.getAccount()
     if pAcct.getAccountType() != Account.AccountType.INVESTMENT: continue
     fields.setFieldStatus(txn)
     if not fields.hasSecurity: continue
     if fields.secCurr != security: continue
     if fields.txnType not in [InvestTxnType.DIVIDEND, InvestTxnType.DIVIDENDXFR, InvestTxnType.DIVIDEND_REINVEST]: continue
     # OK - we got one!
     foundTxns.append(txn)
    foundTxns=sorted(foundTxns, key=lambda sort_t: sort_t.getDateInt())
    for txn in foundTxns:  # yes this is repetative...
     fields.setFieldStatus(txn)
     pAcct=txn.getAccount()
     secAcct=fields.security
     if fields.secCurr != security: raise Exception("LOGIC ERROR: - '%s' != '%s'!?" %(fields.secCurr, security))
     balAsOf=AccountUtil.getBalanceAsOfDate(book, secAcct, txn.getDateInt()) 
     totDivvy=fields.amount
     divvy=0.0 if balAsOf == 0L else fields.curr.getDoubleValue(totDivvy)/security.getDoubleValue(balAsOf)
     print "Date: %s, Type: %s, Shares held in acct: %s, Total Divvy: %s, Fee: %s, Calc Divvy: %s, Acct currency: %s, Security account: %s,"\
          %(fmt.format(txn.getDateInt()), fields.txnType, security.formatFancy(balAsOf, "."), fields.curr.formatFancy(totDivvy, "."), fields.fee, StringUtils.formatRate(divvy, ".",4), fields.curr, secAcct.getFullAccountName())
    print "FINISHED"
    

    (I'm not sure what effect splits has on this. It's probably OK as we are reporting the divvy and balance on the actual dates recorded, but I haven't tested this)

  2. 2 Posted by dwg on 20 Feb, 2025 05:10 AM

    dwg's Avatar

    Not having the record date will create questions around accuracy.

  3. 3 Posted by Mekky SB on 20 Feb, 2025 02:22 PM

    Mekky SB's Avatar

    Hi,

    Agree!

    I've wanted the dividend payout rates recorded in the dividend history too and MD uses this information to automatically calculate the entitled dividend amount based on the holdings on the record dates. This would be helpful when I look back to see the payout rate history and the payout frequency rather than just the dividend amounts paid.

    Looking forward to seeing this new functionality in MD.

    Thanks.

  4. 4 Posted by Stuart Beesley ... on 20 Feb, 2025 02:24 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    Run the script and see how it works for you? Edit line one to change the ticker

Reply to this discussion

Internal reply

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

Attaching KB article:

»

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

Recent Discussions

24 Apr, 2025 03:49 PM
24 Apr, 2025 03:28 PM
24 Apr, 2025 01:33 PM
24 Apr, 2025 11:23 AM
24 Apr, 2025 09:55 AM