def __test_impl(self, action):
        order = backtesting.MarketOrder(
            action, BaseTestCase.TestInstrument, 25, False, broker.IntegerTraits()
        )
        price = 10
        volumeUsed = 0

        # Try the order once.
        slippedPrice = self.slippage.calculatePrice(
            order, price, order.getQuantity(), self.barsBuilder.nextBar(10, 11, 9, 10, volume=100), volumeUsed
        )
        quantity = order.getQuantity()
        expectedPriceImpactPct = quantity/100.0 * quantity/100.0 * self.priceImpact
        self.assertEqual(expectedPriceImpactPct, 0.00625)
        if action == broker.Order.Action.BUY:
            self.assertEqual(slippedPrice, price * (1 + expectedPriceImpactPct))
        else:
            self.assertEqual(slippedPrice, price * (1 - expectedPriceImpactPct))

        # Try the same order once again.
        volumeUsed += quantity
        quantity += order.getQuantity()

        slippedPrice = self.slippage.calculatePrice(
            order, price, order.getQuantity(), self.barsBuilder.nextBar(10, 11, 9, 10, volume=100), volumeUsed
        )
        expectedPriceImpactPct = quantity/100.0 * quantity/100.0 * self.priceImpact
        self.assertEqual(expectedPriceImpactPct, 0.025)
        if action == broker.Order.Action.BUY:
            self.assertEqual(slippedPrice, price * (1 + expectedPriceImpactPct))
        else:
            self.assertEqual(slippedPrice, price * (1 - expectedPriceImpactPct))
dataset/ETHPy150Open gbeced/pyalgotrade/testcases/slippage_model_test.py/VolumeShareSlippageTestCase.__test_impl/original