示例#1
0
 def test_sorted_holdings_value(self):
     """ Test get_sorted_holdings_value """
     stock_data = StockData()
     ts = [Transaction(4, 2.5, date=self.get_today(-4)),  # 2.5, 2.5, 2.5, 2.5
           Transaction(-2, 3.2, date=self.get_today(-3)), # 2.5, 2.5 
           Transaction(1, 3.0, date=self.get_today(-2)),  # 2.5, 2.5, 3.0
           Transaction(2, 2.6, date=self.get_today(-1)),  # 2.5, 2.5, 2.6, 2.6, 3.0
           Transaction(-3, 2.9, date=self.get_today(0))]  # 2.6, 3.0
     for t in ts:
         stock_data.apply_transaction(t)
         
     # Total holding should be 5.6
     self.assertEqual(stock_data.holding, 2)
     self.assertEqual(stock_data.transactions, ts)
     self.assertEqual(stock_data.sorted_holdings_value(), 5.6)