code: def update(self, quantity, price, commission):
      assert quantity != 0, "Invalid quantity"
      assert price > 0, "Invalid price"
      assert commission >= 0, "Invalid commission"
  
      if self.__position == 0:
          self.__openNewPosition(quantity, price)
      else:
          # Are we extending the current position or going in the opposite direction ?
          currPosDirection = math.copysign(1, self.__position)
          tradeDirection = math.copysign(1, quantity)
  
          if currPosDirection == tradeDirection:
              self.__extendCurrentPosition(quantity, price)
          else:
              # If we're going in the opposite direction we could be:
              # 1: Partially reducing the current position.
              # 2: Completely closing the current position.
              # 3: Completely closing the current position and opening a new one in the opposite direction.
              if abs(quantity) <= abs(self.__position):
                  self.__reduceCurrentPosition(quantity, price)
              else:
                  newPos = self.__position + quantity
                  self.__reduceCurrentPosition(
                      self.__position * -1, price
                  )
                  self.__openNewPosition(newPos, price)
  
      self.__commissions += commission
  
imports: import math
  from pyalgotrade import stratanalyzer
  from pyalgotrade import observer
  from pyalgotrade import dataseries
label_desc: Use image node_id 11 for calling the PositionTracker obj's underlying member method code with example usage: obj.update(quantity, price, commission) without return types