code: def testSomeTrades(self):
      strat = self.__createStrategy()
      stratAnalyzer = trades.Trades()
      strat.attachAnalyzer(stratAnalyzer)
  
      # Winning trade
      strat.addOrder(
          buildUTCDateTime(2011, 1, 3, 15, 0),
          strat.getBroker().createMarketOrder,
          broker.Order.Action.BUY,
          TradesAnalyzerTestCase.TestInstrument,
          1,
      )  # 127.14
      strat.addOrder(
          buildUTCDateTime(2011, 1, 3, 15, 16),
          strat.getBroker().createMarketOrder,
          broker.Order.Action.SELL,
          TradesAnalyzerTestCase.TestInstrument,
          1,
      )  # 127.16
      # Losing trade
      strat.addOrder(
          buildUTCDateTime(2011, 1, 3, 15, 30),
          strat.getBroker().createMarketOrder,
          broker.Order.Action.BUY,
          TradesAnalyzerTestCase.TestInstrument,
          1,
      )  # 127.2
      strat.addOrder(
          buildUTCDateTime(2011, 1, 3, 15, 31),
          strat.getBroker().createMarketOrder,
          broker.Order.Action.SELL,
          TradesAnalyzerTestCase.TestInstrument,
          1,
      )  # 127.16
      # Winning trade
      strat.addOrder(
          buildUTCDateTime(2011, 1, 3, 15, 38),
          strat.getBroker().createMarketOrder,
          broker.Order.Action.BUY,
          TradesAnalyzerTestCase.TestInstrument,
          1,
      )  # 127.16
      strat.addOrder(
          buildUTCDateTime(2011, 1, 3, 15, 42),
          strat.getBroker().createMarketOrder,
          broker.Order.Action.SELL,
          TradesAnalyzerTestCase.TestInstrument,
          1,
      )  # 127.26
      # Open trade.
      strat.addOrder(
          buildUTCDateTime(2011, 1, 3, 15, 47),
          strat.getBroker().createMarketOrder,
          broker.Order.Action.BUY,
          TradesAnalyzerTestCase.TestInstrument,
          1,
      )  # 127.34
      strat.run()
  
      self.assertTrue(
          round(strat.getBroker().getCash(), 2)
          == round(
              1000
              + (127.16 - 127.14)
              + (127.16 - 127.2)
              + (127.26 - 127.16)
              - 127.34,
              2,
          )
      )
  
      self.assertTrue(stratAnalyzer.getCount() == 3)
      self.assertTrue(stratAnalyzer.getEvenCount() == 0)
      self.assertTrue(round(stratAnalyzer.getAll().mean(), 2) == 0.03)
      self.assertTrue(
          round(stratAnalyzer.getAll().std(ddof=1), 2) == 0.07
      )
      self.assertTrue(
          round(stratAnalyzer.getAll().std(ddof=0), 2) == 0.06
      )
  
      self.assertTrue(stratAnalyzer.getProfitableCount() == 2)
      self.assertTrue(
          round(stratAnalyzer.getProfits().mean(), 2) == 0.06
      )
      self.assertTrue(
          round(stratAnalyzer.getProfits().std(ddof=1), 2) == 0.06
      )
      self.assertTrue(
          round(stratAnalyzer.getProfits().std(ddof=0), 2) == 0.04
      )
  
      self.assertTrue(stratAnalyzer.getUnprofitableCount() == 1)
      self.assertTrue(
          round(stratAnalyzer.getLosses().mean(), 2) == -0.04
      )
      if version.LooseVersion(
          numpy.__version__
      ) >= version.LooseVersion("1.6.2"):
          self.assertTrue(
              math.isnan(stratAnalyzer.getLosses().std(ddof=1))
          )
      else:
          self.assertTrue(stratAnalyzer.getLosses().std(ddof=1) == 0)
      self.assertTrue(stratAnalyzer.getLosses().std(ddof=0) == 0)
  
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 6 for calling the TradesAnalyzerTestCase obj's underlying member method code with example usage: obj.testSomeTrades() without return types