示例#1
0
 def update_accumulator(self, container):
     """Add stocks received as bonus shares do the accumulator."""
     new_quantity = container.state['quantity'] * self.factor
     container.state['price'] = average_price(
         container.state['quantity'], container.state['price'],
         new_quantity, 0
     )
     container.state['quantity'] += new_quantity
示例#2
0
 def test_case_02(self):
     price = utils.average_price(10, 1, 10, 3)
     self.assertEqual(price, 2)
示例#3
0
 def test_case_00(self):
     price = utils.average_price(10, 2, 10, 4)
     self.assertEqual(price, 3)