Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Help with back test - dividend inflow / outflow

Hi Q,

Attached is a long / short back test. There are several stocks that wen't ex-dividend and paid out dividends during this period. Where do I see this in back test results? How can I reconcile the dividend payments? Please advise.

Best regards,
Pravin

3 responses

I don't believe there's any specific way of tracking the sources of cash flows.

Dividends from a stock you're long simply magically increase your cash position. (To see this, write and backtest an algorithm that calculates every day, or every minute, how many shares, with commissions, it can afford to buy with the cash on hand, buys if greater than zero, and never sells. Then look at the list of transactions. You could also record(cash=context.portfolio.cash).) I suppose you could carefully track your cash, and attribute discrepancies to dividends. Likewise, mutatis mutandis, for stocks you're short, where you're charged the dividend amount you must pay to the owner of the shares.

To determine which dates to examine and what amounts to expect, you could use a dividend database like this.