Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Recording dividend income

Hi everyone!

I want to compare some strategies based on dividend income. I know dividends are added to portfolio cash on the payout date and I wonder if someone can recommend (or share) some code that records dividends?

Thanks!

4 responses

Hi all,

Here are the two solutions I came up with. One attempts to count the cash that is accumulating. The other attempts to track based on the dividends per share metric. They produce significantly different results, but I do understand why. The cash accumulating method is probably more accurate, and it's definitely easier. It also shows "bigger" results, which is the only "downside". (I prefer to underestimate vs overestimate).

In the end, my use case is to compare strategies using the "dividend returns" metric and i'll be calculating it the same way for all strategies so, it will be an apples to apples comparison.

Ill attach. both algos here. I'd be interested to see what people think, and if anyone has some helpful ideas or better methods.

Thanks,
Brett

Method 1: Since dividends are paid out as cash additions to the account, I just count the accumulating cash before I rebalance once a year.

Method 2: Setup a second pipeline and use the dividend_per_share_earnings_reports factor.

Well, now of course, i want to test an algo that trades once a month and both my solutions no longer work. Anyone have any ideas?