def _maybe_earn_dividend(self, dividend):
     """
     Take a historical dividend record and return a Series with fields in
     zipline.protocol.DIVIDEND_FIELDS (plus an 'id' field) representing
     the cash/stock amount we are owed when the dividend is paid.
     """
     if dividend['sid'] in self.positions:
         return self.positions[dividend['sid']].earn_dividend(dividend)
     else:
         return zp.dividend_payment()
Exemple #2
0
 def _maybe_earn_dividend(self, dividend):
     """
     Take a historical dividend record and return a Series with fields in
     zipline.protocol.DIVIDEND_FIELDS (plus an 'id' field) representing
     the cash/stock amount we are owed when the dividend is paid.
     """
     if dividend['sid'] in self.positions:
         return self.positions[dividend['sid']].earn_dividend(dividend)
     else:
         return zp.dividend_payment()
 def _maybe_pay_dividend(self, dividend):
     """
     Take a historical dividend record, look up any stored record of
     cash/stock we are owed for that dividend, and return a Series
     with fields drawn from zipline.protocol.DIVIDEND_PAYMENT_FIELDS.
     """
     try:
         unpaid_dividend = self._unpaid_dividends.loc[dividend['id']]
         return unpaid_dividend
     except KeyError:
         return zp.dividend_payment()
Exemple #4
0
 def _maybe_pay_dividend(self, dividend):
     """
     Take a historical dividend record, look up any stored record of
     cash/stock we are owed for that dividend, and return a Series
     with fields drawn from zipline.protocol.DIVIDEND_PAYMENT_FIELDS.
     """
     try:
         unpaid_dividend = self._unpaid_dividends.loc[dividend['id']]
         return unpaid_dividend
     except KeyError:
         return zp.dividend_payment()
Exemple #5
0
    def earn_dividend(self, dividend):
        """
        Register the number of shares we held at this dividend's ex date so
        that we can pay out the correct amount on the dividend's pay date.
        """
        assert dividend['sid'] == self.sid
        out = {'id': dividend['id']}

        # stock dividend
        if dividend['payment_sid']:
            out['payment_sid'] = dividend['payment_sid']
            out['share_count'] = floor(self.amount * float(dividend['ratio']))

        # cash dividend
        if dividend['net_amount']:
            out['cash_amount'] = self.amount * dividend['net_amount']
        elif dividend['gross_amount']:
            out['cash_amount'] = self.amount * dividend['gross_amount']

        payment_owed = zp.dividend_payment(out)
        return payment_owed
Exemple #6
0
    def earn_dividend(self, dividend):
        """
        Register the number of shares we held at this dividend's ex date so
        that we can pay out the correct amount on the dividend's pay date.
        """
        assert dividend['sid'] == self.sid
        out = {'id': dividend['id']}

        # stock dividend
        if dividend['payment_sid']:
            out['payment_sid'] = dividend['payment_sid']
            out['share_count'] = floor(self.amount * float(dividend['ratio']))

        # cash dividend
        if dividend['net_amount']:
            out['cash_amount'] = self.amount * dividend['net_amount']
        elif dividend['gross_amount']:
            out['cash_amount'] = self.amount * dividend['gross_amount']

        payment_owed = zp.dividend_payment(out)
        return payment_owed