'Given a list of dividends whose ex_dates are all the next trading day,
calculate and store the cash and/or stock payments to be paid on each
dividend\'s pay date.
Parameters
dividends: iterable of (asset, amount, pay_date) namedtuples
stock_dividends: iterable of (asset, payment_asset, ratio, pay_date)
namedtuples.'

def earn_dividends(self, dividends, stock_dividends):

    for dividend in dividends:
        div_owed = self.positions[dividend.asset].earn_dividend(dividend)
        try:
            self._unpaid_dividends[dividend.pay_date].append(div_owed)
        except KeyError:
            self._unpaid_dividends[dividend.pay_date] = [div_owed]
    for stock_dividend in stock_dividends:
        div_owed = self.positions[stock_dividend.asset].earn_stock_dividend(stock_dividend)
        try:
            self._unpaid_stock_dividends[stock_dividend.pay_date].append(div_owed)
        except KeyError:
            self._unpaid_stock_dividends[stock_dividend.pay_date] = [div_owed]
