code: def testProportionalCommissionBug(self):
      # Regression test for a bug reported by 'Jackson Sam' on 30/Aug/2013.
      strat = self.__createStrategy()
      strat.getBroker().setCommission(backtesting.FixedPerTrade(0.01))
      stratAnalyzer = trades.Trades()
      strat.attachAnalyzer(stratAnalyzer)
  
      # There are 3 trades here:
      # Trade 1 (Long)
      #   Buy 1 @ 127.16 Commission: 0.01
      #   Sell 1 @ 127.26 Commission: 0.005
      # Trade 2 (Short)
      #   Sell 1 @ 127.26 Commission: 0.005
      #   Buy 1 @ 127.37 Commission: 0.005
      # Trade 3 (Long)
      #   Buy 1 @ 127.37 Commission: 0.005
      #   Sell 1 @ 127.4 Commission: 0.01
  
      strat.addOrder(
          buildUTCDateTime(2011, 1, 3, 15, 38),
          strat.getBroker().createMarketOrder,
          broker.Order.Action.BUY,
          TradesAnalyzerTestCase.TestInstrument,
          1,
      )  # Fill at 127.16
      strat.addOrder(
          buildUTCDateTime(2011, 1, 3, 15, 42),
          strat.getBroker().createMarketOrder,
          broker.Order.Action.SELL,
          TradesAnalyzerTestCase.TestInstrument,
          2,
      )  # Fill at 127.26
      strat.addOrder(
          buildUTCDateTime(2011, 1, 3, 15, 53),
          strat.getBroker().createMarketOrder,
          broker.Order.Action.BUY,
          TradesAnalyzerTestCase.TestInstrument,
          2,
      )  # Fill at 127.37
      strat.addOrder(
          buildUTCDateTime(2011, 1, 3, 15, 58),
          strat.getBroker().createMarketOrder,
          broker.Order.Action.SELL,
          TradesAnalyzerTestCase.TestInstrument,
          1,
      )  # Fill at 127.4
  
      strat.run()
      allReturns = stratAnalyzer.getAllReturns()
      self.assertEqual(round(allReturns[0], 6), 0.000668)
      self.assertEqual(round(allReturns[1], 6), -0.000943)
      self.assertEqual(round(allReturns[2], 6), 0.000118)
  
imports: import datetime
  import math
  from distutils import version
  import pytz
  import numpy
  from .None import common
  from .None import strategy_test
  from .None import position_test
  from pyalgotrade.barfeed import ninjatraderfeed
  from pyalgotrade.barfeed import csvfeed
  from pyalgotrade.stratanalyzer import trades
  from pyalgotrade import broker
  from pyalgotrade.broker import backtesting
label_desc: Use image node_id 8 for calling the TradesAnalyzerTestCase obj's underlying member method code with example usage: obj.testProportionalCommissionBug() without return types