original_docstring: 
          Add order to orders, create position and tradestat if necessary.
  
          Parameters
          ----------
          task : Task
  
          
docstring: Add order to orders, create position and tradestat if necessary.
  Parameters
  
  task : Task
docstring_tokens: Add order to orders create position and tradestat if necessary . Parameters task : Task
code: def add_task(self, task):
          """
          Add order to orders, create position and tradestat if necessary.
  
          Parameters
          ----------
          task : Task
  
          """
          if task.task_id in self.tasks:
              print('duplicate task {}'.format(task.task_id))
          
          # Store Task (right after strategy constructs a task)
          # TODO: copy
          self.tasks[task.task_id] = copy.deepcopy(task)
          
          # Store/Update TradeStat (right after strategy constructs a task)
          if task.function_name == 'place_order':
              order = task.data
              # self.orders[order.entrust_no] = order
              self._update_trade_stat_from_order(order)
          
          elif task.function_name == 'place_batch_order':
              orders = task.data
              for order in orders:
                  # self.orders[order.entrust_no] = order
                  self._update_trade_stat_from_order(order)
          
          elif task.function_name == 'basket_order':
              # TODO: no Order class for basket_order
              raise NotImplementedError("basket_order")
          
          elif task.function_name == 'goal_portfolio':
              # self._update_trade_stat_from_goal_positions(goal_positions)
              #orders = task.data
              for entrust_no, order in task.data.items():
                  self._update_trade_stat_from_order(order)
code_tokens: def add_task ( self , task ) : if task . task_id in self . tasks : print ( 'duplicate task {}' . format ( task . task_id ) ) self . tasks [ task . task_id ] = copy . deepcopy ( task ) if task . function_name == 'place_order' : order = task . data self . _update_trade_stat_from_order ( order ) elif task . function_name == 'place_batch_order' : orders = task . data for order in orders : self . _update_trade_stat_from_order ( order ) elif task . function_name == 'basket_order' : raise NotImplementedError ( "basket_order" ) elif task . function_name == 'goal_portfolio' : for entrust_no , order in task . data . items ( ) : self . _update_trade_stat_from_order ( order )
short_docstring: Add order to orders, create position and tradestat if necessary.
short_docstring_tokens: Add order to orders create position and tradestat if necessary .
comment: """
          Add order to orders, create position and tradestat if necessary.
  
          Parameters
          ----------
          task : Task
  
          """$SEP$# Store Task (right after strategy constructs a task)$SEP$# TODO: copy$SEP$# Store/Update TradeStat (right after strategy constructs a task)$SEP$# self.orders[order.entrust_no] = order$SEP$# self.orders[order.entrust_no] = order$SEP$# TODO: no Order class for basket_order$SEP$# self._update_trade_stat_from_goal_positions(goal_positions)$SEP$#orders = task.data