Пример #1
0
 def get_current_dividend(self):
     cur_div = Decimal(0)
     cur_div = ystockquote.get_dividend_per_share(self.symbol)
     try:
         cur_div = Decimal(cur_div)
     except:
         pass
     return cur_div
Пример #2
0
def calculate_portfolio_dividends(portfolio, holdings):
    total_dividends = Decimal(0)
    for holding_obj in holdings:
        symbol = holding_obj.security.symbol
        if symbol != 'CASH':
            dividend = 0
            try: 
                dividend = Decimal(ystockquote.get_dividend_per_share(symbol))
            except:
                pass
            dividend = Decimal(holding_obj.held) * Decimal(dividend)
            total_dividends = total_dividends + dividend
    
    return total_dividends
Пример #3
0
 def test_get_dividend_per_share(self):
     value = ystockquote.get_dividend_per_share(self.symbol)
     self.assertIsInstance(value, str)
Пример #4
0
 def test_get_dividend_per_share(self):
     value = ystockquote.get_dividend_per_share(self.symbol)
     self.assertIsInstance(value, str)