docstr: Parameters
  ----------
  score:
      pred score for this trade date, pd.Series, index is stock_id, contain 'score' column
  current:
      current position, use Position() class
  trade_date:
      trade date
  
      generate target position from score for this date and the current position
  
      The cache is not considered in the position
docstr_tok: ["Parameters","--","--","--","--","--","score",":","pred","score","for","this","trade","date",",","pd.Series",",","index","is","stock_id",",","contain","'score","'","column","current",":","current","position",",","use","Position","(",")","class","trade_date",":","trade","date","generate","target","position","from","score","for","this","date","and","the","current","position","The","cache","is","not","considered","in","the","position"]
code: def generate_target_weight_position(
      self, score, current, trade_start_time, trade_end_time
  ):
      """
      Parameters
      ----------
      score:
          pred score for this trade date, pd.Series, index is stock_id, contain 'score' column
      current:
          current position, use Position() class
      trade_date:
          trade date
  
          generate target position from score for this date and the current position
  
          The cache is not considered in the position
      """
      # TODO:
      # If the current stock list is more than topk(eg. The weights are modified
      # by risk control), the weight will not be handled correctly.
      buy_signal_stocks = set(
          score.sort_values(ascending=False).iloc[: self.topk].index
      )
      cur_stock_weight = current.get_stock_weight_dict(only_stock=True)
  
      if len(cur_stock_weight) == 0:
          final_stock_weight = {
              code: 1 / self.topk for code in buy_signal_stocks
          }
      else:
          final_stock_weight = copy.deepcopy(cur_stock_weight)
          sold_stock_weight = 0.0
          for stock_id in final_stock_weight:
              if stock_id not in buy_signal_stocks:
                  sw = min(
                      self.max_sold_weight, final_stock_weight[stock_id]
                  )
                  sold_stock_weight += sw
                  final_stock_weight[stock_id] -= sw
          if self.buy_method == "first_fill":
              for stock_id in buy_signal_stocks:
                  add_weight = min(
                      max(
                          1 / self.topk
                          - final_stock_weight.get(stock_id, 0),
                          0.0,
                      ),
                      sold_stock_weight,
                  )
                  final_stock_weight[stock_id] = (
                      final_stock_weight.get(stock_id, 0.0) + add_weight
                  )
                  sold_stock_weight -= add_weight
          elif self.buy_method == "average_fill":
              for stock_id in buy_signal_stocks:
                  final_stock_weight[stock_id] = final_stock_weight.get(
                      stock_id, 0.0
                  ) + sold_stock_weight / len(buy_signal_stocks)
          else:
              raise ValueError("Buy method not found")
      return final_stock_weight
  
file_path: qlib/qlib/contrib/strategy/cost_control.py
imports: from .order_generator import OrderGenWInteract
  from .signal_strategy import WeightStrategyBase
  import copy
label_desc: Use image node_id 3 for calling the SoftTopkStrategy obj's underlying member method code with example usage: obj.generate_target_weight_position(score, current, trade_start_time, trade_end_time) and returns: final_stock_weight