def test_to_str(self): self.assertEqual(dollars.to_str(D('10.50')), '$10.50') self.assertEqual(dollars.to_str(D('1234.99')), '$1234.99') self.assertEqual(dollars.to_str(D('1.2345')), '$1.23') self.assertEqual(dollars.to_str(D('1234.5678')), '$1234.57') self.assertEqual(dollars.to_str(D('-1.2345')), '$(1.23)') self.assertEqual(dollars.to_str(D('-1234.5678')), '$(1234.57)')
def _dollar_str(self, value): return dollars.to_str(value, limit_precision=False, accounting_style=False)
def __repr__(self): if self.amount > 0: return '%s Deposited %s' % ( self.date, dollars.to_str(self.amount)) return '%s Withdrew %s' % (self.date, dollars.to_str(self.amount))
def __str__(self): return '%s Dividend of %s from %s%s%s' % \ (self.date, dollars.to_str(self.amount), self.symbol, ' (qualified)' if self.qualified else '', ' - reinvested' if self.reinvested else '')
def __repr__(self): return '%s Sold %.2f %s at %s - %s fee' % ( self.date, self.num_shares, self.symbol, dollars.to_str(self.price), dollars.to_str(self.fees))
def __repr__(self): return '%s Bought %.2f %s at %s%s - %s fee' % ( self.date, self.num_shares, self.symbol, dollars.to_str(self.price), ' (reinvestment)' if self.is_reinvestment else '', dollars.to_str(self.fees))
def __repr__(self): return '%s Interest: %s' % (self.date, dollars.to_str(self.amount))
def __repr__(self): return '%s %s liquidation of %s' % (self.date, dollars.to_str(self.amount), self.description[:30])
def __repr__(self): return '%s %s-Term Cap Gain of %s from %s%s' % ( self.date, 'Long' if self.long_term else 'Short', dollars.to_str(self.amount), self.symbol, ' - reinvested' if self.reinvested else '')