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
def test_case_02(self): price = utils.average_price(10, 1, 10, 3) self.assertEqual(price, 2)
def test_case_00(self): price = utils.average_price(10, 2, 10, 4) self.assertEqual(price, 3)