Dividends#

The DividendTransactions class consumes raw dividend records (richy.shares.models.Dividend / richy.etfs.models.Dividend) and the user’s transaction history, and creates one ShareDividendTransaction (or EtfDividendTransaction) row per (user, dividend) pair, recording how many shares the user held on the dividend’s payment date and the total cash payout.

The class is instantiated for a single asset – pass exactly one of share= or etf= to the constructor. Calling calculate() walks every user with at least one transaction. Dividends with a future payment date are skipped; positions closed before the payment date receive no dividend record; any previously-created records for users who no longer hold the asset are deleted on the next calculate() pass.

DividendTransactions#

class richy.transactions.dividends.DividendTransactions(*, share=None, etf=None)[source]#

Bases: object

This class handles ShareDividendTransaction or EtfDividendTransaction model creation/update. It calculates based on Transaction (currently owned stocks) and shares.Dividend (dividend data) transactions that are income for share holder.

DividendTransactions.calculate()[source]#

Calculates (creates/updates) ShareDividendTransaction or EtfDividendTransaction model records based on owned stocks now and in past.

Also recalculates/removes already created transaction in the past.