class_docstr: Keeps and updates the size and price of a position. The object has no
  relationship to any asset. It only keeps size and price.
  
  Member Attributes:
    - size (int): current size of the position
    - price (float): current price of the position
  
  The Position instances can be tested using len(position) to see if size
  is not null
class_docstr_tok: ["Keeps","and","updates","the","size","and","price","of","a","position",".","The","object","has","no","relationship","to","any","asset",".","It","only","keeps","size","and","price",".","Member","Attributes",":","-","size","(","int",")",":","current","size","of","the","position","-","price","(","float",")",":","current","price","of","the","position","The","Position","instances","can","be","tested","using","len","(","position",")","to","see","if","size","is","not","null"]
code: def set(self, size, price):
      if self.size > 0:
          if size > self.size:
              self.upopened = size - self.size  # new 10 - old 5 -> 5
              self.upclosed = 0
          else:
              # same side min(0, 3) -> 0 / reversal min(0, -3) -> -3
              self.upopened = min(0, size)
              # same side min(10, 10 - 5) -> 5
              # reversal min(10, 10 - -5) -> min(10, 15) -> 10
              self.upclosed = min(self.size, self.size - size)
  
      elif self.size < 0:
          if size < self.size:
              self.upopened = size - self.size  # ex: -5 - -3 -> -2
              self.upclosed = 0
          else:
              # same side max(0, -5) -> 0 / reversal max(0, 5) -> 5
              self.upopened = max(0, size)
              # same side max(-10, -10 - -5) -> max(-10, -5) -> -5
              # reversal max(-10, -10 - 5) -> max(-10, -15) -> -10
              self.upclosed = max(self.size, self.size - size)
  
      else:  # self.size == 0
          self.upopened = self.size
          self.upclosed = 0
  
      self.size = size
      self.price_orig = self.price
      if size:
          self.price = price
      else:
          self.price = 0.0
  
      return self.size, self.price, self.upopened, self.upclosed
  
file_path: backtrader/backtrader/position.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  from copy import copy
label_desc: Use image node_id 4 for calling the Position obj's underlying member method code with example usage: obj.set(size, price) and returns: self,  self,  self,  self