class_docstr: A :class:`pyalgotrade.stratanalyzer.StrategyAnalyzer` that records the profit/loss
  and returns of every completed trade.
  
  .. note::
      This analyzer operates on individual completed trades.
      For example, lets say you start with a $1000 cash, and then you buy 1 share of XYZ
      for $10 and later sell it for $20:
  
          * The trade's profit was $10.
          * The trade's return is 100%, even though your whole portfolio went from $1000 to $1020, a 2% return.
code: def __onOrderEvent(self, broker_, orderEvent):
      # Only interested in filled or partially filled orders.
      if orderEvent.getEventType() not in (
          broker.OrderEvent.Type.PARTIALLY_FILLED,
          broker.OrderEvent.Type.FILLED,
      ):
          return
  
      order = orderEvent.getOrder()
  
      # Get or create the tracker for this instrument.
      try:
          posTracker = self.__posTrackers[order.getInstrument()]
      except KeyError:
          posTracker = returns.PositionTracker(
              order.getInstrumentTraits()
          )
          self.__posTrackers[order.getInstrument()] = posTracker
  
      # Update the tracker for this order.
      execInfo = orderEvent.getEventInfo()
      price = execInfo.getPrice()
      commission = execInfo.getCommission()
      action = order.getAction()
      if action in [
          broker.Order.Action.BUY,
          broker.Order.Action.BUY_TO_COVER,
      ]:
          quantity = execInfo.getQuantity()
      elif action in [
          broker.Order.Action.SELL,
          broker.Order.Action.SELL_SHORT,
      ]:
          quantity = execInfo.getQuantity() * -1
      else:  # Unknown action
          assert False
  
      self.__updatePosTracker(posTracker, price, commission, quantity)
  
imports: from pyalgotrade import stratanalyzer
  from pyalgotrade import broker
  from pyalgotrade.stratanalyzer import returns
  import numpy
label_desc: Use image node_id 4 for calling the Trades obj's underlying member method code with example usage: obj.__onOrderEvent(broker_, orderEvent) without return types