code: def testLongShort2(self):
      strat = self.__createStrategy()
      stratAnalyzer = trades.Trades()
      strat.attachAnalyzer(stratAnalyzer)
  
      # Enter long
      strat.addOrder(
          buildUTCDateTime(2011, 1, 3, 15, 0),
          strat.getBroker().createMarketOrder,
          broker.Order.Action.BUY,
          TradesAnalyzerTestCase.TestInstrument,
          1,
      )  # 127.14
      # Exit long
      strat.addOrder(
          buildUTCDateTime(2011, 1, 3, 15, 16),
          strat.getBroker().createMarketOrder,
          broker.Order.Action.SELL,
          TradesAnalyzerTestCase.TestInstrument,
          1,
      )  # 127.16
      # Enter short
      strat.addOrder(
          buildUTCDateTime(2011, 1, 3, 15, 16),
          strat.getBroker().createMarketOrder,
          broker.Order.Action.SELL_SHORT,
          TradesAnalyzerTestCase.TestInstrument,
          1,
      )  # 127.16
      # Exit short
      strat.addOrder(
          buildUTCDateTime(2011, 1, 3, 15, 30),
          strat.getBroker().createMarketOrder,
          broker.Order.Action.BUY_TO_COVER,
          TradesAnalyzerTestCase.TestInstrument,
          1,
      )  # 127.2
      strat.run()
  
      self.assertTrue(
          round(strat.getBroker().getCash(), 2)
          == round(1000 + (127.16 - 127.14) + (127.16 - 127.2), 2)
      )
  
      self.assertTrue(stratAnalyzer.getCount() == 2)
      self.assertTrue(stratAnalyzer.getEvenCount() == 0)
  
      self.assertTrue(round(stratAnalyzer.getAll().mean(), 2) == -0.01)
      self.assertTrue(
          round(stratAnalyzer.getAll().std(ddof=1), 4) == 0.0424
      )
  
      self.assertTrue(stratAnalyzer.getProfitableCount() == 1)
      self.assertTrue(
          round(stratAnalyzer.getProfits().mean(), 2) == 0.02
      )
  
      self.assertTrue(stratAnalyzer.getUnprofitableCount() == 1)
      self.assertTrue(
          round(stratAnalyzer.getLosses().mean(), 2) == -0.04
      )
  
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 10 for calling the TradesAnalyzerTestCase obj's underlying member method code with example usage: obj.testLongShort2() without return types